Which day of the week (Sunday, Monday, etc.) is the probability largest to fall on the 13th of a random month, in a random year?
Or is this probability the same for each day of the week?
Ordinarily we consider a leap year to take place once every four years. Under this circumstance, four years contain 365*4 + 1 = 1461 days, or 208 weeks plus 5 days. As 5 is relatively prime to 7, the number of days in a week, it would follow that whatever imbalances in days of the week that occur within that 4year period would be balanced by every day of the week to experience every position within that cycle if carried over 7 cycles, or 28 years.
However, in the Gregorian calendar, certain years that are multiples of four, and therefore would ordinarily be considered leap years, are made into ordinary years. Those years are years ending in 00, but not themselves divisible by 400. So 1700, 1800 and 1900 were not leap years even though divisible by 4, because they were divisible by 100 (ending in 00), but not by 400. Year 2000 was the exception to the exceptionit was divisible by 400, and therefore was a leap year.
So 3 out of 4 centuries are missing a leap day. Four centuries would otherwise be 36525*4 = 146100 days, but with the removal of these 3 days, they add to only 146097 days. That makes this cycle equal to exactly 20871 weeks, so any imbalance in the days of the week will not be compensated for by other cycles having different imbalances.
We can take any 400year period in the Gregorian calendar, and count how many 13th of the month fell on each day of the week, and that is the overall distribution. January 13, 2000, was a Thursday. Based on that and the lengths of the months, with consideration for the leap year rules, the following program:
DATA 31,28,31,30,31,30,31,31,30,31,30,31
DIM moLen(12)
FOR i = 1 TO 12: READ moLen(i): NEXT
PRINT
dow = 5
mo = 1: year = 2000
DO
dCt(dow) = dCt(dow) + 1
dow = (dow + moLen(mo)) MOD 7
IF mo = 2 THEN
IF year MOD 4 = 0 THEN
IF (year MOD 400 = 0) OR (year MOD 100 <> 0) THEN
dow = dow + 1 ' could change 0 to 1 or 6 to 7 but that's ok
END IF
END IF
END IF
IF dow = 0 THEN dow = 7
mo = mo + 1
IF mo > 12 THEN
mo = mo  12: year = year + 1
END IF
LOOP UNTIL year > 2399
FOR i = 1 TO 7
PRINT dCt(i);
NEXT
finds the distribution of days (Sunday to Saturday):
687 685 685 687 684 688 684
so Friday is the most common, followed by Sunday and Wednesday tied, and then by Monday and Tuesday tied.
However, the problem speaks of a "random month, in a random year". It does not specify the random distribution used, or the method of randomization. If years before 1582 are included, then a good portion are still in the Julian calendar, that did have leap year every 4 years (going back to 45 BC, before which even more complicated rules held). October 1582 itself did not even have a 13th, going directly from the 4th to the 15th, to transition from the Julian calendar to the Gregorian. Also, the average Gregorian year is 365.2425 days long, while the average year according to the seasons is 365.2422 days long. Some have said that this should cause a further refinement to be made in the calendar, over the long haul. In fact, though, the earth's rotation is slowing down (causing fewer solar days per seasonal year), so that by the time one more day should be added, the length of the seasonal year would differ by still more from the Gregorian average. So some sort of calendar adjustment will be needed.
On a more personal level, since the last time a quadrennial leap year was missed was 1900, and the next time one will be missed will be 2100, in our lifetimes there is in effect a leap year every four years. Assuming uniform birth rates, for example, we would expect people alive today who are born on the 13th of the month, would be equally likely to have been born on any day of the week with equal probability, and if we die on the 13th of a month it would be equally likely to be any day of the week. Any deviations would be because people are more likely to be born or die on given days of the week than because of the structure of the calendar.

Posted by Charlie
on 20040813 09:54:43 