The Doomsday Algorithm is a method for calculating the day of the week for any given date that’s easy enough it can be done mentally very quickly. When you get good enough at it, it really does look like a superpower and it’s a great trick for impressing friends and family. For example:
Me: Hey, would you believe me if I told you that I memorized the whole calendar?
You: There’s no way you could do that. When was my birthday, 12th of June 2002?
Me: that was a… Wednesday. The 2nd of the month actually!
You: 😮
The algorithm was designed by John Conway in 1973, who got so good at it that he could usually give the correct answer in under two seconds, and he even programmed his computer to quiz him with random dates every time he logged on - only he could so it was a great password!
The technique revolves around the fact that certain dates of the year will always fall on the same day of the week - we call this day doomsday. If we could calculate which day of the week this would be for a certain year (and remember one of these special days for each month), we could hypothetically easily find the day of the week for any day of the year. This is exactly what the doomsday algorithm accomplishes!
Anyone can learn this!
It might seem dawnting at first and a lot to remember, but it’s made so that all you need to do is add small numbers together. With only a little practice you can easily do it in under 30 seconds!
Useful links:
- The Doomsday Algorithm - Numberphile YouTube video
- Doomsday rule Wikipedia article
- doomsday CLI tool for explanations and testing
- John Conway himself describing the algorithm
Date math
Lets establish a common ‘language’ for doing maths with dates, which if you try to do with the names of the days (Monday, Tuesday, etc) is really difficult - for example, what’s 19 days after Thursday? Instead, we represent the days with numbers which allows for much easier calculations:
Day | Mnemonic | Number |
---|---|---|
Sunday | “Noneday” | 0 |
Monday | “Oneday” | 1 |
Tuesday | “Twosday” | 2 |
Wednesday | “Threesday” | 3 |
Thursday | “Foursday” | 4 |
Friday | “Fiveday” | 5 |
Saturday | “Sixaday” | 6 |
Now “19 days after Thursday” becomes 4 + 19 = 23. But what day of the week is 23? To simplify further notice how after exactly one week, or 7 days, you will always get the same day of the week. This means that 7 days after Thursday is still a Thursday, as well as 14 days after, 21 days after, 28 days after, etc. That means that 23 is really the same as 23 - 21 = 2. Finally, we’ve found that 19 days after Thursday is a Tuesday!
Finding the day of the week
As I said before, the technique uses the fact that every year has a special ‘doomsday’ which we can use to find the date for any date of the year. There are only 3 simple things that you need to calculate and add together:
- The doomsmonth,
- The doomsyear,
- And the doomscentury
Doomsday
The doomsyear and doomscentury added together is the doomsday for that year. Remembering the doomsday for whatever year you’re currently reading this is in is useful and lets you skip most of the steps!
Example
Throughout this we’ll be using the date 1969-11-16, or the 16th of July 1969, as an example and in the end we’ll figure out it’s day of the week. Hopefully by the end you will learn the tools to find the day of the week for any date!
Doomsmonth
Here’s a fun fact: In any year, all of the following dates will be on the same day of the week:
- 3/1 or 4/1 on leap years
- 0/2 or 1/2 on leap years
- 0/3
- 4/4, 6/6, 8/8, 10/10, 12/12
- 5/9, 9/5
- 7/11, 11/7
Not only will they all be the same, they’re all a doomsday! That’s why, given any month, you should be able to quickly recite what day of that month is a doomsday. It looks daunting at first, but there are a few tricks you can use to make it easier:
- The “0th” day of March
- All the even months (after March) have doomsdays on the same number day
- The mnemonic “I work from 9-to-5 at the 7-11” to remember the odd months
All you have to do to find the doomsmonth is to subtract the day of the month that’s a doomsday from the date you’re given. That’s it! What we’re really doing here is finding how far ahead the given day is from a doomsday, which we’ll soon learn how to find what day of the week it is.
Leap years
If your date is in the month of January or February you need to know if the year is a lap year or not. This can be annoying, but there’s no way around it. A year is a leap year if:
- The year is divisible by 4, unless
- The year is divisible by 100 (ends in 00) it is NOT a leap year, except if
- The year is also divisible by 400.
Example
For the 16th of July 1969 (which is the 7th month), we know from the list above that the 11th of July is a doomsday. This means the doomsmonth is 16 - 11 = 5. So if the doomsday for 1969 was a Monday (1), we’d know that the 16th of July 1969 was a Saturday! (1 + 5 = 6
)
Doomsyear
Finding how far away the given date is from the doomsday is well and all, but it’s not very useful if we don’t happen to know what the doomsday is for a certain year. That’s where the doomsyear and doomscentury come in! What we’ll focus on first is the doomsyear, which is based on the first two numbers of the year - i.e. the XX part of 20XX.
For every year that goes on, the doomsday increases by one. That’s except for leap years which add another day on as well. That’s really it! So if we knew the doomsday for the year 2000 (lets say x
), it would just be the next day for 2001 (x + 1
), the day after that for 2002 (x + 2
), the next day for 2003 (x + 3
), then it would skip an extra day for 2004 because it is a leap year (x + 5
). So on and so forth!
As you can imagine, this would get tedious for higher years. There’s a trick though: 0, 28, 56 and 84 all have a doomsyear of 0. This means all we have to do is add how many years ahead we are from one of these 4 key years, and also add how many leap years there are which is just the difference divided by 4 (ignore any fraction part). This is the hardest part of the whole algorithm, but it gets easier with practice.
Example
For the 16th of July 1969 the doomsyear focuses on just “69”, which is 13 years ahead of 56 (69 - 56 = 13
). We also know that in this 13 years there were 3 whole leap years (13 // 4 = 3
) Adding these two numbers together, the doomsyear is 13 + 3 = 16.
Doomscentury
This is the last missing piece in our puzzle and by far the easiest part. The doomscentury tells what the doomsday was on the first year of every century, and all you need to do is remember these centuries:
Century | Doomscentury |
---|---|
1800 | 5 |
1900 | 3 |
2000 | 2 |
2100 | 0 |
An easy way to remember it is that “Y2K” has a doomscentury of 2. But what if you wanted to find for centuries beyond 1800 and 2100? Just subtract/add 400 years until they’re in that range. For example, the doomscentury for 2700 is the same as 2300 is the same as 1900, which is 3. Simple enough!
Example
For the 16th of July 1969, 1900 corresponds to a doomscentury of 3. That’s it!
Bringing it all together
What remains to finding the day of the week? Well, we already know what day of the week doomsday is for the given year (the doomsyear + doomscentury), and we know how far away the given date is from a doomsday (the doomsmonth). What’s left to do is to add everything together! More often than not, adding everything together results in a number larger than 7 - don’t forget you can get rid of all the 7’s and get a number between 0 and 6. This is the day of the week, and the algorithm is complete!
Example
We previously found that for the 16th of July 1969, the doomsmonth was 5, doomsyear was 16, and doomscentury was 3. Adding it all up, we get 5 + 16 + 3 = 24
. We can also remove all the 7’s: 24 - 7 * 3 = 24 - 21 = 3
. We’ve finally found that the 16th of July 1969 was a Wednesday! Were we right?
If you didn’t recognize it, on the 16th of July in 1969 was when the Apollo 11 spaceflight launched that first landed humans on the Moon!
Tips & Tricks
Here is a list of useful tips to make the whole process much easier:
-
Keep a running result instead of trying to remember multiple numbers. Although nice to wrap your head around the concept, doing it exactly as above can be difficult because you need to calculate then remember a couple different numbers, as well as the original date. This gets difficult really fast, and is very error prone! Instead, have only one number you constantly modify by adding/removing terms to with the following process:
- Start with the date you’re given.
- Subtract from this the day of the month that’s a doomsday - what you have now is the doomsmonth.
- Find and add onto this number the doomscentury.
- Find and add onto this number the doomsyear.
- Find what day of the week this is and you’re done!
- If it makes the number easier, forget 7’s! If at the end of any step in the process I mentioned in the previous tip you have a multiple of 7, that means it is the same as 0 and you can essentially forget about it and start fresh on the next step. This makes it sooo much easier since most of the time you can just “discard” everything you’ve done till then and continue from 0. Plus, it’s really satisfying!
- Don’t be afraid of negative numbers. Sometimes you might end on a negative number, such as -5. What day of the week is that? Just add 7 to make it positive; so for -5, It’s actually 2 which is a Tuesday. Embracing negative numbers can sometimes make your calculations easier and faster - for example, If you find at the end of step 2 of the process from the previous tip you get a doomsmonth of 5, sometimes it’s easier to instead of think of this as -2 and actually just subtract two instead of adding 5. It’s up to you!
Examples
Example #1: 10th of February, 1708
- Start with the date you’re given - in this example that’s just 10
- Subtract from this the day of the month that’s a doomsday
- In February which day is a doomsday depends on if it’s a leap year - our year, 1708, is divisble by 4 (and it doesn’t end in 00) so it is!
- The doomsday in February on leap years is the 1st and we need to subtract 1
-
10 - 1 = 9
(9 is the doomsmonth)
- Find and add onto this number the doomscentury
- We don’t know what it is for 1700, but
1700 + 400 = 2100
and the doomscentury for 2100 is 0 9 + 0 = 9
- We don’t know what it is for 1700, but
- Find and add onto this number the doomsyear
- For “08” we count from the year 00. It’s 8 years ahead, and in those 8 years there are 2 leap years.
- So, the doomsyear is 8 + 2 = 10
9 + 10 = 19
- Find what day of the week this is
- Lets get rid of 7’s:
19 - 7 = 12
, and12 - 7 = 5
- Finally, 5 as we know is Friday.
- Lets get rid of 7’s:
So the 10th of February 1708 was a Friday!
This example had nothing too difficult, we just had to remember to account for leap years in the 2nd step because the month was February and the year was a leap year.
Example #2: 5th of November, 2047
- Start with the date you’re given - here that’s just 5
- Subtract from this the day of the month that’s a doomsday
- In November (the 11th month), the doomsday is on the 7th (think working 9-5 at the 7-11) and we need to subtract 7
5 - 7 = -2
- We’ve got a negative number! We could add 7 to this to make it positive without affecting the result, but lets continue on because something interesting happens:
- Find and add onto this number the doomscentury
- We know the doomscentury for 2000 is 2
-2 + 2 = 0
- It’s cancelled out and we got back to 0! When this happens you get a fresh start and you can forget about everything up until now and just start from the next step. Pretty neat!
- Find and add onto this number the doomsyear
- For “47” we count from the year 28. It’s 19 years ahead, and in those 19 years there are 4 leap years (
19 // 4 = 4
, or as I like to think 16 is the lowest multiple of 4) - So, the doomsyear is 19 + 4 = 23
- Since we ended the last step on 0, now we’ve just got
23
- For “47” we count from the year 28. It’s 19 years ahead, and in those 19 years there are 4 leap years (
- Find what day of the week this is
- Lets get rid of 7’s: the largest multiple of 7 that fits into 23 is 21, which leaves a remainer of
2
. - Finally, 2 is Tuesday.
- Lets get rid of 7’s: the largest multiple of 7 that fits into 23 is 21, which leaves a remainer of
So the 5th of November 2047 will be a Tuesday!
This example showed how using negative numbers can come in handy and end up simplifying steps. Lets just look at one more example that shows another trick to make the calculations easier:
Example #3: 20th of January, 1895
- Start with the date you’re given - again, here that’s 20
- Subtract from this the day of the month that’s a doomsday
- In January which day is a doomsday depends on if it’s a leap year - our year, 1893, is NOT divisble by 4 meaning it’s not a leap year
- The doomsday in January on non-leap years is the 3rd and we need to subtract 3
20 - 3 = 17
- This is a big number and takes longer to do mental maths with. Notice however that it’s not far from a multiple of 7, 14. So lets just get rid of it!
-
17 - 14 = 3
Much better!
- Find and add onto this number the doomscentury
- For the 1800s, the doomscentury is 5
3 + 5 = 8
- Find and add onto this number the doomsyear
- For “95” we count from the year 84. It’s 11 years ahead, and in those 11 years there are 2 whole leap years.
- So, the doomsyear is 11 + 2 = 13
8 + 13 = 21
- Again, this is a multiple of 7 so lets get rid of it and continue with a clean slate!
21 - 21 = 0
- Find what day of the week this is
- What do we have? Just 0, which we know is Sunday.
So the 20th of January 1895 was a Sunday and we’re done!
What next?
Congratulations if you really made it this far! From here, it’s just practice practice practice - the ol’ adage that “Practice makes Perfect” absolutely applies, and you’ll only get faster at this by trying more and more dates. Try doing a couple a day for a minute and see the progress you make. That being said, there are also more intermediate/advanced concepts you can apply to get faster:
- Start calculating as the date is being read out to you. Since most people will start with the day first, you can essentially start straight from step 1. When they get to the month, start working on step 2 before they even get time to think of a year. This is a neat little cheat that will make it much more impressive how quickly you can recall days!
- When calculating the doomsyear we said that 0, 28, 56 and 84 all have a doomsyear of 0. This still leaves big gaps and is still sometimes difficult. Instead, just think about your twelves timestable. 12 has a doomsyear of 1, 24 has 2, 36 has 3, so on and so forth up to 84 having a doomsyear of 7 (I actually like to think of this as 0) and 96 having a doomsyear of 8 (or alternatively 1). This is the method I prefer as it is quick and easy to calculate, and always keeps the year close.
- If even this doesn’t tickle your fancy, there’s been a recent discovery of a new algorithm which is short, dead simple to calculate and highly effective: The Odd+11 method. You can find the original paper that discussed this new method here, but this is the short version of the steps:
- If the year is odd, add 11
- Half the result
- If the result is odd, add 11
- Find how far the result is from the next highest multiple of 7
Of course, none of this would exist if it wasn’t for John Conway for originally creating the Doomsday Algorithm. Sadly, as of writing this post, he has recently passed away. But his contributions to the mathematical and computer science community were immense and his ideas will continue to be taught and learnt from for generations to come.