This article is from the Calendars FAQ, by Claus Tondering email@example.com with numerous contributions by others.
The first day of the calendary year, Rosh HaShanah, on 1 Tishri is
determined as follows:
1) The new year starts on the day of the new moon that occurs about
354 days (or 384 days if the previous year was a leap year) after
1 Tishri of the previous year
2) If the new moon occurs after noon on that day, delay the new year
by one day. (Because in that case the new crescent moon will not be
visible until the next day.)
3) If this would cause the new year to start on a Sunday, Wednesday,
or Friday, delay it by one day. (Because we want to avoid that
Yom Kippur (10 Tishri) falls on a Friday or Sunday, and that
Hoshanah Rabba (21 Tishri) falls on a Sabbath (Saturday)).
4) If two consecutive years start 356 days apart (an illegal year
length), delay the start of the first year by two days.
5) If two consecutive years start 382 days apart (an illegal year
length), delay the start of the second year by one day.
Note: Rule 4 can only come into play if the first year was supposed
to start on a Tuesday. Therefore a two day delay is used rather that a
one day delay, as the year must not start on a Wednesday as stated in