# Friday the 13th frequency

Yesterday was Friday the 13th. This may have passed you by if you’re an adult in full possession of your faculties, because you don’t go looking for calendrical coincidences. But because this was the third Friday the 13th of the year, this one got a little more attention than usual. As you might expect, there were some dumb things said about it on Twitter.

Several of the tweets look like this:

Friday the 13th occurs 3 times this year, each 13 weeks apart from the other. This won’t happen again for 666 years. Happy Friday the 13th.
— The Illuminati (@ThelIluminati) Fri Jul 13 2012 7:32 PM CDT

The 13-week separation of this year’s F13s is true, but the 666 year gap is obvious bullshit.1 Calendars usually repeat at least once every 28 years because a 28-year period typically contains seven leap years and therefore

21*365 + 7*366 = 10,227


days, which is exactly 1461 weeks.2 So the calendar for 1984 (ooh, spooky!) was the same as this year’s calendar, and so will be the calendar for 2040. You can check this out using the venerable Unix cal utility. Here’s the output for cal 1984:

                             1984

January               February               March
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6  7            1  2  3  4               1  2  3
8  9 10 11 12 13 14   5  6  7  8  9 10 11   4  5  6  7  8  9 10
15 16 17 18 19 20 21  12 13 14 15 16 17 18  11 12 13 14 15 16 17
22 23 24 25 26 27 28  19 20 21 22 23 24 25  18 19 20 21 22 23 24
29 30 31              26 27 28 29           25 26 27 28 29 30 31

April                  May                   June
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6  7         1  2  3  4  5                  1  2
8  9 10 11 12 13 14   6  7  8  9 10 11 12   3  4  5  6  7  8  9
15 16 17 18 19 20 21  13 14 15 16 17 18 19  10 11 12 13 14 15 16
22 23 24 25 26 27 28  20 21 22 23 24 25 26  17 18 19 20 21 22 23
29 30                 27 28 29 30 31        24 25 26 27 28 29 30

July                 August              September
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6  7            1  2  3  4                     1
8  9 10 11 12 13 14   5  6  7  8  9 10 11   2  3  4  5  6  7  8
15 16 17 18 19 20 21  12 13 14 15 16 17 18   9 10 11 12 13 14 15
22 23 24 25 26 27 28  19 20 21 22 23 24 25  16 17 18 19 20 21 22
29 30 31              26 27 28 29 30 31     23 24 25 26 27 28 29
30
October               November              December
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6               1  2  3                     1
7  8  9 10 11 12 13   4  5  6  7  8  9 10   2  3  4  5  6  7  8
14 15 16 17 18 19 20  11 12 13 14 15 16 17   9 10 11 12 13 14 15
21 22 23 24 25 26 27  18 19 20 21 22 23 24  16 17 18 19 20 21 22
28 29 30 31           25 26 27 28 29 30     23 24 25 26 27 28 29
30 31


And here it is for cal 2012:

                             2012

January               February               March
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6  7            1  2  3  4               1  2  3
8  9 10 11 12 13 14   5  6  7  8  9 10 11   4  5  6  7  8  9 10
15 16 17 18 19 20 21  12 13 14 15 16 17 18  11 12 13 14 15 16 17
22 23 24 25 26 27 28  19 20 21 22 23 24 25  18 19 20 21 22 23 24
29 30 31              26 27 28 29           25 26 27 28 29 30 31

April                  May                   June
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6  7         1  2  3  4  5                  1  2
8  9 10 11 12 13 14   6  7  8  9 10 11 12   3  4  5  6  7  8  9
15 16 17 18 19 20 21  13 14 15 16 17 18 19  10 11 12 13 14 15 16
22 23 24 25 26 27 28  20 21 22 23 24 25 26  17 18 19 20 21 22 23
29 30                 27 28 29 30 31        24 25 26 27 28 29 30

July                 August              September
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6  7            1  2  3  4                     1
8  9 10 11 12 13 14   5  6  7  8  9 10 11   2  3  4  5  6  7  8
15 16 17 18 19 20 21  12 13 14 15 16 17 18   9 10 11 12 13 14 15
22 23 24 25 26 27 28  19 20 21 22 23 24 25  16 17 18 19 20 21 22
29 30 31              26 27 28 29 30 31     23 24 25 26 27 28 29
30
October               November              December
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6               1  2  3                     1
7  8  9 10 11 12 13   4  5  6  7  8  9 10   2  3  4  5  6  7  8
14 15 16 17 18 19 20  11 12 13 14 15 16 17   9 10 11 12 13 14 15
21 22 23 24 25 26 27  18 19 20 21 22 23 24  16 17 18 19 20 21 22
28 29 30 31           25 26 27 28 29 30     23 24 25 26 27 28 29
30 31


I leave cal 2040 as an exercise for the reader.

How frequent are years with three F13s? Here’s a little Python script that uses the datetime library to find out:

python:
1:  #!/usr/bin/python
2:
3:  from datetime import date
4:
5:  counts = {}
6:  unlucky = {}
7:  for year in range(1990, 2150):
8:    counts[year] = 0
9:    unlucky[year] = []
10:    for month in range(1, 13):
11:      test = date(year, month, 13)
12:      if test.weekday() == 4:  # 0=Mon, 1=Tue, ..., 4=Fri
13:        counts[year] += 1
14:        unlucky[year].append(test.strftime("%b"))
15:
16:  for k in sorted(counts.keys()):
17:    if counts[k] >= 3:
18:      print k, unlucky[k]


The output is

1998 ['Feb', 'Mar', 'Nov']
2009 ['Feb', 'Mar', 'Nov']
2012 ['Jan', 'Apr', 'Jul']
2015 ['Feb', 'Mar', 'Nov']
2026 ['Feb', 'Mar', 'Nov']
2037 ['Feb', 'Mar', 'Nov']
2040 ['Jan', 'Apr', 'Jul']
2043 ['Feb', 'Mar', 'Nov']
2054 ['Feb', 'Mar', 'Nov']
2065 ['Feb', 'Mar', 'Nov']
2068 ['Jan', 'Apr', 'Jul']
2071 ['Feb', 'Mar', 'Nov']
2082 ['Feb', 'Mar', 'Nov']
2093 ['Feb', 'Mar', 'Nov']
2096 ['Jan', 'Apr', 'Jul']
2099 ['Feb', 'Mar', 'Nov']
2105 ['Feb', 'Mar', 'Nov']
2108 ['Jan', 'Apr', 'Jul']
2111 ['Feb', 'Mar', 'Nov']
2122 ['Feb', 'Mar', 'Nov']
2133 ['Feb', 'Mar', 'Nov']
2136 ['Jan', 'Apr', 'Jul']
2139 ['Feb', 'Mar', 'Nov']


From this, we see that in years with three F13s, they always occur in either January, April, and July, like this year, or February, March, and November, which is more common. (Note also that because I used >= in the test in Line 17, this script should also capture years with four or more F13s. There aren’t any.)

The reason for the Feb-Mar-Nov combination is easy to figure out. You’ve certainly noticed that in non-leap years, March and February start on the same day of the week, because February is exactly four weeks long. You may not have noticed—I never did until just now—that March and November always start on the same day of the week, because

Mar + Apr + May + Jun + Jul + Aug + Sep + Oct
31  + 30  + 31  + 30  + 31  + 31  + 30  + 31  = 245


which is exactly 35 weeks. The same is true for April and July, because

Apr + May + Jun
30  + 31  + 30  = 91


which is exactly 13 weeks.

In leap years, January and April also line up because

Jan + Feb + Mar
31  + 29  + 31  = 91


This is why this year’s three F13s are 13 weeks apart.

Where else in the calendar are months 91 days apart? Just one other spot:

Sep + Oct + Nov
30  + 31  + 30  = 91


So September and December always start on the same day of the week. If there’s an F13 in September, there’ll be another in December. Check out cal 2013.

One last month alignment: In non-leap years, January and October start on the same weekday, because

Jan + Feb + Mar + Apr + May + Jun + Jul + Aug + Sep
31  + 28  + 31  + 30  + 31  + 30  + 31  + 31  + 30  = 273


is exactly 39 weeks.

That certain days of the year always fall on the same day of the week is the basis for John Conway’s Doomsday algorithm, a method (which I’ve never been able to keep memorized for more than a day or two) for mentally calculating the day of the week for any given date.

Calendar arithmetic is harmless fun and can be surprisingly complex. The best source I know of for calendar algorithms of all types, including conversions between different types of calendar, is Dershowitz and Reingold’s Calendrical Calculations. The code in the book is in Lisp (it’s where the calendar module in Emacs comes from), but the explanations are so clear that even non-Lispers can follow along (and might even learn some Lisp in the process).

1. Yes, I realize that someone tweeting under the handle @TheIlluminati could be doing satire, but it doesn’t seem like a joke account, and too many others tweeted the same thing for all of them to be joking.

To be fair, most Twitter users aren’t nonsense-repeating idiots. Many tweets pointed out the 13-week separation and correctly said that it last happened in 1984. ↩︎

2. The 28-year repetition cycle gets messed up near century years that aren’t divisible by 400 because they aren’t leap years. ↩︎