Note: This is a talk I gave to the campers of PROMYS 2022, lightly adapted for text.
Motivation
When new to a social environment, it’s often useful to have some sort of fun party trick or icebreaker you can use. Now, here’s an example of something impressive which will wow your friends and your foes alike - after this, you’ll be able to calculate the day of the week for any day in history!1
The Doomsday algorithm
There is a long history of algorithms for calculating the day of the week, including some by Lewis Carroll (the author of Alice in Wonderland) and Carl Friedrich Gauss, but the algorithm which we will learn is the so-called Doomsday algorithm. It was invented by the late John Conway in 1973, and requires nothing more than some memorization and mental math. He had his computer quiz him with a random date to login, and as a result he got his time down to around two seconds.
The main ingredient in this algorithm is Conway’s observation that several easy-to-memorize dates all fall on the same day of the week every year, the so called “doomsdays.” (Conway had a somewhat eclectic sense of humor.) For instance, April 4th, June 6th, August 8th, October 10th, and December 12th will always be on the same day of every year, no matter what year you choose. So, given some random year, if we can calculate what day of week Doomsday is on, we can simply count forward or backward to the date we care about.
We will use several mnemonics to remember the Doomsdays. For sake of convention, we will use the American MM/DD date format.
For even months:
As mentioned above, the even months have their double dates, with 4/4, 6/6, 8/8, 10/10, and 12/12. For February, it is the last day of the month, i.e. 2/28 in a normal year and 2/29 in a leap year.
For odd months:
I work from 9 to 5 at the 7-11.2
With this, we see that the Doomsdays are 9/5, 5/9, 7/11, and 11/7. For January, we remember 1/3 in a normal year and 1/4 in leap years. You can remember this as being on the 3rd for 3 years out of 4 and the 4th every 4 years. For March, we remember Pi Day (3/14) is on Doomsday.
Reminder 1. In the Gregorian calendar system which we use, leap years are years which are divisible by 4 (e.g. 2020), except if the year was divisible by 100 (e.g. 1700, 1800, and 1900 were NOT leap years), unless the year is also divisible by 400 (e.g. 2000 WAS a leap year).
Example 1. Let’s calculate the day of the week of David’s very special day (when he finds out about his NIST crypto submission),3 July 5th, 2022. Doomsday for 2022 is on Monday, and so July 11th is on a Monday. This means that July 4th is also on a Monday, so July 5th is a Tuesday.
Remark 1. It may help to remember that Valentine’s Day (2/14), U.S. Independence Day (7/4), and Halloween (10/31) are all on Doomsday. Christmas (12/25) is the day before Doomsday.
Calculating Doomsday (for the 21st century)
Okay, this is all fine and good, but how do we actually calculate the Doomsday given a year? The idea is to memorize the Doomsday for 2000 (Tuesday), which is known as the “anchor day,” and calculate the shift to the year we care about. The Doomsday shifts forward one day every year and two days every leap year, but this is tedious to compute the farther into the century we get. Thankfully, there exist algorithms to compute it easier. Conway came up with one, but I prefer the simpler “odd + 11” method found by Fong and Walters. As the name suggests, it involves repeated use of the “odd + 11” rule.
The algorithm will involve the use of a running total $T$.
-
Let $T$ be the last two digits of the year.
-
If $T$ is odd, add 11.
-
Let $T=\frac{T}{2}$.
-
If $T$ is odd, add 11.
-
Let $T=7-(T\text{ mod } 7)$.
-
Add $T$ to the anchor day mod 7.
Remark 2. The final step is equivalent to simply subtracting $T$ from the anchor day mod 7, but counting backward days in your head is harder for me than doing it forward. Do what works better for you.
Example 2. Let’s calculate the Doomsday for 2015.
-
Let $T=15$.
-
$T=15+11=26$. (15 is odd)
-
Let $T=\frac{T}{2}=13$.
-
$T=13+11=24$. (13 is odd)
-
Let $T=7-(24 \text{ mod } 7)=4$.
-
$4+\text{Tuesday}=\textbf{Saturday}$.
Expanding to different centuries
This process will work for any century we choose, but we just need to memorize the anchor days. Since the Gregorian calendar repeats every 400 years, we only need to memorize four of them and use modular arithmetic to find the rest.
\[\begin{array}{|c|c|} \hline \textbf{Century} & \textbf{Anchor Day} \\ \hline 1900-1999 & \text{Wednesday} \\ \hline 2000-2099 & \text{Tuesday} \\ \hline 2100-2199 & \text{Sunday} \\ \hline 2200-2299 & \text{Friday} \\ \hline \end{array}\]For most practical purposes, you’ll only need to remember Wednesday for the 1900s and Tuesday for the 2000s (that’s when people you’re likely to meet have their birthdays), but it’s good to know the other days. Conway came up with “We-in-dis-day”4, and Y2K for Tuesday.5 Unfortunately, I don’t have a mnemonic on hand for the other two anchor days, though there is a formula. If $c$ is the first two digits of the year, then
\[\text{anchor day}=\text{Tuesday}+5(c\text{ mod } 4)\text{ mod } 7.\]Example 3. Let’s calculate the day of the week of Emmy Noether’s birthday, March 23rd, 1882. The anchor day for the 1800s is Friday, and using the odd + 11 method, we see that the shift is 4 days. So, the Doomsday for 1882 is Tuesday, and thus we know March 14th was a Tuesday. Counting forward we see that March 23rd was a Thursday.
Other calendars
A little bit of a history lesson is in order. On January 1st, 45 BCE, the Julian calendar proposed by Julius Caesar went into effect. The way it was set up, it gave an average year length of 365.25 days, slightly longer than the 365.2422 days it actually is. While this doesn’t seem like much, this caused the calendar to drift forward a little less than a day a century. By the time the 1500s rolled around, the spring equinox in the Northern Hemisphere was meaningfully behind when it usually was ($\sim$March 21st).
This was a problem because the date was how Christian churches calculated when Easter was, so Pope Gregory XIII instituted the Gregorian calendar most of the world uses today, with the leap year rule that we already talked about. Thursday, October 4th 1582 was followed by Friday, October 15 1582, with ten days missing. So, if you have a date before then, you would technically need to use the Julian calendar.
The process for the Julian calendar is very similar to the Gregorian calendar – it’s actually simpler. If $c$ is the first two digits of the year, then \(\text{anchor day}=\text{Sunday}+6c\text{ mod } 7.\)
Example 4. The anchor day for 1300 is \(\text{Sunday}+ 6\cdot 3\text{ mod } 7=\text{Saturday}.\)
The rest of the algorithm proceeds as usual – calculate the shift, and then count forward or backward to your desired date.
Additional reading
This exposition heavily relied upon the Wikipedia article for the Doomsday algorithm, and it is an excellent reference. The website http://rudy.ca/doomsday.html is another good reference, and also covers the “hand method” which Conway used (and I do not know). It also contains additional links to still more interesting resources on related topics.
-
Okay, it’s a little more complicated than that. Read on to find out more! ↩
-
Some cultural notes: 7-11 is a convenience store chain, and 9 to 5 are typical American work hours. ↩
-
We would find out later at PROMYS that David’s cryptosystem, SIKE, was broken in a very spectacular way. At the time of the talk, however, we didn’t know that yet. ↩
-
i.e. “We in this day”, as most people alive today were born then. ↩
-
Y2K was a huge panic in 2000 where certain people were scared that the large-scale rollover into the new century would cause a global blackout of technology due to bugs in handling years and lead to a subsequent return to the Dark Ages. No, I’m not making this up. (Note: I was surprised to see how many of the PROMYS students recognized this!) ↩