It’s going to be a bit of a strange year for Friday the 13ths.  First of all, there will be three of them.  Now that’s not especially weird–it happens every few years–but it’s the first time since 1984 that they’ll be spaced precisely 13 weeks apart.  It’s also the last time until 2040 that we’ll have three of them in a leap year.  I got all this information from a story on the USA Today website, which featured some words from one Dr. Tom Fernsler of the University of Delaware, a math professor (naturally) who’s earned himself the nickname of “Dr. 13.”  An interesting tidbit from the good doctor, and bad news for the phobic: the 13th of the month is actually more likely to occur on a Friday than any other day of the week–688 times in a 400-year period.

To a math geek like me, this raises at least two immediate questions: (1) If being spaced 13 weeks apart is strange, how far apart are Friday the 13ths spaced on average?  (2) If Friday is the most common day for a 13th, by how much?  Short of digging through a couple centuries’ worth of calendars, is there a way to answer these questions?  Of course there is, and to do it we’ll turn to modular arithmetic and a guy named Christian Zeller.

Zeller was an 19th-century German mathematician.  Aside from his instruction in math, Zeller was also trained in theology–he was even director of a seminary for awhile–and mathematically inclined Christian theologians (or theologically inclined Christian mathematicians, I suppose) are obsessed with calendrical calculation.  Why?

Easter is a big deal for Christians–maybe the biggest of deals–but it has a major problem: it’s a lunar holiday floating around in a solar calendar.  Easter, after all, is rooted in the Jewish holiday of Passover, and the Jewish calendar is lunar (mostly).  To make matters worse, the lunar benchmarks for calculating Easter aren’t even based on actual astronomical observations, but on some kind of hypothetical “Ecclesiastical Full Moon” harkening back, again, to the Hebrew calendar.

Now there’s nothing wrong with lunar calendars per se, but they require constant tweaking to keep dates from wandering too far in reference to the seasons.  For example, if you think a leap year is weird, consider that the Hebrew calendar has to add an entire 13th lunar month seven times every 19 years to keep things straight.  When you combine the lunar weirdness with the fact that everybody who’s anybody in the Christian church has been using a solar calendar (whether Gregorian or Julian) since basically forever, you begin to understand why the Eastern and Western churches still can’t agree on a single date for the holiday (though they do accidentally coincide once in a great while).  All of this, of course, is a long way of saying that people have spent an awful lot of time thinking about the mathematics of dates.

Zeller decided that the cyclical nature of the days, months, and years, made them perfect for modular arithmetic, and in 1883 he published a paper containing a formula for calculating the day of the week for a given date by combining the day, month, year, and century modulo 7.  Now it’s called Zeller’s Congruence:

$h = \left(q+\left\lfloor \frac{13(m+1)}{5} \right\rfloor + K + \left\lfloor \frac{K}{4} \right\rfloor + \left\lfloor \frac{J}{4} \right\rfloor - 2J \right) \pmod{7}$

With some minor modifications, Zeller’s Congruence does very nicely inside of computer programs, and so I spent some of my Saturday (meaning today is 0 mod 7) developing a little Python program to bring some math to bear on this Friday the 13th issue.

I, like Dr. 13, will consider a period of 400 years.  (Incidentally, the reason for choosing that particular time period is that a 400-year block includes all of the quirks associated with leap years, i.e., if a year is divisible by 4, then it’s a leap year…unless it’s also divisible by 100, in which case it’s not…unless it’s also divisible by 400, in which case it is…again.)  I used Zeller’s Congruence to generate a list of all the Friday the 13ths between now and 2412.

Anyway, assuming the Gregorian calendar is still in use for the next four centuries, we will indeed experience 688 Friday the 13ths, but we’ll also have 684 Saturdays, 687 Sundays, 685 Mondays, 685 Tuesdays, 687 Wednesdays, and 684 Thursdays.  So yes, a Friday the 13th is the most likely variety of 13th, but not by very much (as you would expect).

But what about this business of waiting time?  It turns out that the average number of days between Friday the 13ths is just over 212, or about 30 weeks.  The least amount of time possible is a measly 28 days (the next time we’ll have back-to-back bad luck months is in February and March of 2015), and the most amount of time possible is more than a year: 427 days.  And that nice long respite is coming up quickly; after our triple-whammy this year (which ends on Fri, July 13th), we won’t have to bite our nails again until September of 2013.

Here is what the waiting times look like for the next 400 years:

Time, in days, between consecutive occurences

As an interesting note, in order to make the arithmetic a little simpler, Zeller considered January and February of any year to be the 13th and 14th months of the previous year, respectively.  That means that, as far as his congruence is concerned, we’re a scant two years away from 13/13/13, which would correspond to January 13th, 2014.

Alas, it’s a Monday.