The days of the week (d.o.w) which are Sunday, Monday,
Tuesday,Wednesday,Thursday,Friday and Saturday (in that order) are respectively denoted by the numbers 0,1,2,3,4,5 and 6 . Any given year commencing with a particular d.o.w is assigned that value corresponding to that d.o.w. For example, the value ‘0’ would be assigned to a year commencing with a Sunday.
# A year is defined as ‘Matched’ if the remainder obtained, when the year is divided by 7, corresponds precisely with the value assigned to that particular year. For example, 2003 A.D. is NOT A Matched year since 2003 leaves a remainder of 1 upon division by 7 but January 1,2003 occurred on a Wednesday which is denoted by 3.
Determine the total number of ‘Matched’ years between 1960 A.D. and 2560 A.D.(both years inclusive) in accordance with the Western (Gregorian) Calendar System.
(In reply to
Analytic solution with computer verification by Charlie)
My previous analysis needlessly separated consideration of the centuries 23012400 and 24012500. This is one contiguous sequence of years in which every fourth is leap, and so the previous analysis was more complex than need be. Here's a replacement:
For any series of years in which there is a leap year every four years, there is a 28year cycle that repeats, as the 4year cycle of leap years is relatively prime to the 7 that is the number of days in the week. So during this period each beginning day of the week and each year remainder (and their combinations) are represented equally, so four out of the 28 are 'matched'. A first approximation to an answer would be (25601959) * 4 / 28 ~= 86. However, the fractional cycles need be accounted for.
The 4year cycle of leap years is interrupted in years ending in 00, but are not divisible by 400. In the time period referenced, these are 2100, 2200, 2300 and 2500. Each of these is a common, rather than leap, year, even though divisible by 4.
From 1960 through 2100 inclusive, is 141 years, or one more than 5 * 28. The five 28year cycles account for 5 * 4 = 20 matches. As the 1960 and 2100 are both at the same position in the 28year cycle, they are either both matches or both nonmatches, so either one can be considered as the extra year (the break in the cycle comes in February, 2100, so Jan 1 is not affected). We'll use 2100: it is 97 years after 2003, or 24 4year cycles plus 1 year. 24 4year cycles advance the dow by 24*5 mod 7 = 1. The extra year, being nonleap (Feb. 2003 or Feb 2099) advances one more day, making a total of 2 days. So Jan 1, 2100 is a Friday (dow=5). But 2100 mod 7 = 0, so there is no match. Therefore 1960 through 2100 accounts for just the 20 matches of its five full 28year cycles.
Then comes 2101 through 2200. Year 2101's dow is 1 past that of 2100 as the latter is nonleap. That makes its dow=6. Its remainder mod 7 is 1. One hundred years is 3*28 + 16. The three 28year cycles account for 3*4=12 match years. We need the extra 16, which might as well be the first 16:
dow: 6 0 1 2 4 5 6 0 2 3 4 5 0 1 2 3
remainder: 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2
Thus these years account for four matches, making the total for 2101 through 2200 equal to 16 matches.
Then come 2201 through 2300. Again there are three 28year cycles accounting for 12 match years, and again we do the first 16 as extra. As the last of the extra 16 years above, we had calculated dow = 3 for year 2116. So year 2200 also has dow = 3, and 2201 has dow = 4, since 2201 is not a leap year. Also, 2201 mod 7 is 3, so the extra 16 years of this cycle have:
dow: 4 5 6 0 2 3 4 5 0 1 2 3 5 6 0 1
remainder: 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4
This yields no matches, so 2201 through 2300 account for just 12 match years.
Then years 2301 through 2500 (a 200year span as 2400 is indeed a leap year) are done similarly. Year 2300 has dow = 1 and 2301 has dow = 2, and 2301 mod 7 = 5, and the span includes 7 28year cycles plus 4 extra years:
dow: 2 3 4 5
remainder: 5 6 0 1
so no matches are in the extra years, but the 7 28year cycles give 28 matches, which is then the total for years 2301 through 2500.
Finally, we have 2501 through 2560. These 60 years are two 28year cycles plus four more years. As 2500 is nonleap, 2501 has dow one higher than that of 2500 (remember that extra years have matching characteristics at the front or at the end of any span):
dow: 6 0 1 2
remainder: 2 3 4 5
for no matches, but the two 28year cycles give 8 matches.
So we have 20 + 16 + 12 + 28 + 8 = 84 as the final answer.

Posted by Charlie
on 20060123 08:24:42 