This article is from the Calendars FAQ, by Claus Tondering email@example.com with numerous contributions by others.
In the Julian calendar the relationship between the days of the week
and the dates of the year is repeated in cycles of 28 years. In the
Gregorian calendar this is still true for periods that do not cross
years that are divisible by 100 but not by 400.
A period of 28 years is called a Solar Cycle. The "Solar Number" of a
year is found as:
Solar Number = (year + 8) mod 28 + 1
In the Julian calendar there is a one-to-one relationship between the
Solar Number and the day on which a particular date falls.
(The leap year cycle of the Gregorian calendar is 400 years, which is
146,097 days, which curiously enough is a multiple of 7. So in the
Gregorian calendar the equivalent of the "Solar Cycle" would be 400
years, not 7*400=2800 years as one might be tempted to believe.)