What is the maximal number of
”Friday the 13th
“ in a calendar year?
Would your answer be the same for ”Friday the 29th “?
leap first Fridays
day relevant dates 13 29
d o w counts
0 1 1 13 9 29 10 13 12 29 2 2
0 2 4 13 6 29 7 13 2 1
0 3 3 29 9 13 11 29 12 13 2 2
0 4 6 13 8 29 1 1
0 5 2 13 3 13 5 29 11 13 3 1
0 6 1 29 8 13 10 29 1 2
0 7 4 29 5 13 7 29 1 2
1 1 1 13 4 13 6 29 7 13 3 1
1 2 3 29 9 13 11 29 12 13 2 2
1 3 2 29 6 13 8 29 1 2
1 4 3 13 5 29 11 13 2 1
1 5 2 13 8 13 10 29 2 1
1 6 1 29 4 29 5 13 7 29 1 3
1 7 9 29 10 13 12 29 1 2
There are at most 3 Friday the 13ths in a year: in ordinary years beginning on a Thursday and in leap years starting on a Sunday.
There are also at most 3 Friday the 29ths in a year: in leap years beginning on a Friday.
DATA 31,28,31,30,31,30,31,31,30,31,30,31
DIM lngth(12)
OPEN "fridays.txt" FOR OUTPUT AS #2
FOR leap = 0 TO 1
RESTORE
FOR i = 1 TO 12: READ lngth(i): NEXT
lngth(2) = lngth(2) + leap
FOR strt = 1 TO 7
PRINT #2, leap; strt,
ct13 = 0: ct29 = 0
stMo = strt: mo = 1
DO
da13 = (stMo + 12) MOD 7
da29 = (stMo + 28) MOD 7
IF da13 = 6 THEN ct13 = ct13 + 1: PRINT #2, mo; 13,
IF da29 = 6 AND 29 <= lngth(mo) THEN ct29 = ct29 + 1: PRINT #2, mo; 29,
stMo = (stMo + lngth(mo)) MOD 7
mo = mo + 1
LOOP UNTIL mo > 12
PRINT #2, TAB(73); ct13; ct29
NEXT strt
NEXT leap
|
Posted by Charlie
on 2014-11-03 10:54:22 |