How would it be if you were able to calculate day of the week for any date? With a little bit of math and logic, anything is possible!
Before you start celebrating, be warned that this technique requires a little bit of effort and practice upfront. But once you understand it and have enough practice, you’ll be pulling off magic-trick-like performances in front of your friends at parties.
The algorithm that I will be demonstrating in this essay is called the Doomsday algorithm and was originally proposed by John Conway in 1973 (link in the references section at the end of the essay). Conway, in turn, had simplified a rule proposed by Lewis Carrol in 1872 to arrive at this algorithm.
The Doomsday algorithm is split into three significant steps:
1. Computing the Doomsday for a given date’s century year.
2. Computing the Doomsday for the specific year of the given date.
3. Computing the precise day of the week for the given date.
Let us begin by defining what a ‘Doomsday’ is.
Defining Doomsdays
To keep things clean and defined upfront, I will be using the following date format throughout this essay: DD/MM/YYYY (Day/Month/Year). Furthermore, I will be demonstrating the Doomsday algorithm for the Gregorian calendar only (used post-September 1752).
From this definition, it becomes clear that the date is comprised of three elements: the day, the month, and the year.
Conway defines a Doomsday for any given year as the day of the week on which the last day of February falls. The Doomsday algorithm then goes on to take advantage of the fact that there are several significant dates in each month of each year that fall on the same day.
In short, if we know on which weekday the last day of February (of a particular year) falls, we know a whole bunch of (more or less) equally spaced dates throughout the year that fall on the same day. Based on this, we could compute the day of the week for any date on that year using simple addition and/or subtraction.
But how do we know on which day of the week the last date of February falls? Well, before we answer that question, let us establish the relationships between the various Doomsdays distributed throughout the year.
Let us start with the low hanging fruits first: January and February:
Image created by the author
January 32nd does not exist in reality (it’s February 1st), but Conway recommends this style of thinking as he feels that it is easier for us to remember the logic.
Next up, we have the even months of the year. These are pretty easy, as given by the list below:
Image created by the author
The odd months of the year are a little trickier but follow a simple logic nonetheless. For any odd month numbered ’n’, the Doomsday is given by n +/- 4. For odd months that are long (31 days), the Doomsday is given by n + 4. For odd months that are short (30 days — September and November only), the Doomsday is given by n-4.
To sum up, the comprehensive Doomsday list one needs to remember looks as follows:
Image created by the author
Once you have this list, you could always add or subtract multiples of 7 to arrive at other doomsdays for the respective year.
Example Calculation
Let us say that we are interested in calculating the day of the week for the date: 30/10/2022
Assume that someone tells us that Doomsdays for the year 2022 occur on Mondays. Based on this information, we could say that the date 10/10/2022 occurs on a Monday. This is because we know that 10/10/2022 is a Doomsday as well. By adding 14, we arrive at the next Doomsday as 24/10/2022. By adding 6 to this date, we arrive at Sunday (Monday + 6) as the answer for 30/10/2022.
But hang on a minute! I was able to do that only because I knew the Doomsday for 2022 (Monday). How do we figure that part out? Right, onward to that question we march.
Computing Doomsday for Any Given Century
Tostart, one needs to just remember that the years 0, 400, 800, 1200, 1600, … are all Tuesdays. Basically, the Doomsdays for all years that are multiples of 400 occur on Tuesdays. For every century after a multiple of 400, Doomsday is retarded by 2 days.
For instance, 2000 is a multiple of 400. So, we could directly say that the Doomsday for this century occurs on a Tuesday as well. On the other hand, 1900 is 300 years (3 centuries) after 1600 (the previous multiple of 400). So, we subtract 6 from Tuesday (2*3) to arrive at Wednesday as the answer.
So far, we have means of computing the Doomsday for any given century year. But what about the years in between two centuries? That is pretty much the final piece of the puzzle we need to solve.
Computing Doomsday for Any Year Within the Century
Let us say that we have already computed the Doomsday for a given century. Each ordinary year has its Doomsday 1 day later than the previous year, and each leap year 2 days later. We could use this to our advantage by splitting each century into multiples of 12.
Such a division would lead to 12, 24, 36, 48, 60, 72, 84, and 96. Say that we are interested in Doomsday for 2012. We know that the Doomsday for 2000 occurs on a Tuesday (based on our ‘Doomsday for any century’ logic).
For any given 12 years (a dozen years), there are a total of 12/4 = 3 leap years. So, for each dozen years, the Doomsday is shifted by (12+3) = 14 + 1 = 1 day. consequently, we add 1 day to Tuesday to arrive at Wednesday as the Doomsday for 2012.
How To Calculate Day of the Week for Any Date
We have finally arrived at the point where we are ready to calculate the day of the week for any date. To show off, let us consider the following date: 20/06/3075. That’s right! This algorithm can be used to calculate the day of the week for future dates as well!
Firstly, let us compute the Doomsday for the century. 3000 occurs 2 centuries after 2800, which is the previous closest multiple of 400. So, for 2800, the Doomsday is Tuesday. For each century after that, we retard Tuesday by 2. Therefore, we subtract 4 from Tuesday to arrive at Friday as the Doomsday for 3000.
Next, we need to calculate the Doomsday for 3075. We know that 12*6 = 72 and 75 = (12*6) + 3. So, we need to add (6+3) days to Friday (the Doomsday for 3000). Furthermore, the number of 4s in 3(75–72 = 3) is zero. This means that there will be 0 leap years from 3072 to 3075. Consequently, we could calculate the Doomsday for 3075 as follows:
Doomsday for 3075 = Friday + (6+3) + 0
= Friday + 9
= Friday + 7 + 2
= Friday + 2
= Sunday!
Now, we know that 06/06/3075 occurs on a Sunday (a Doomsday!). We also know that 14 + 6 = 20. So, 20/06/3075 is also a Doomsday. Therefore, 20/06/3075 occurs on a Sunday as well!
There you have it; that’s pretty much it!
Summary
Tosum up, here is a ten-step process to execute the Doomsday algorithm to your pleasure at any party:
1. Gather an entertaining crowd.
2. Ask a random person to come up with a random date.
3. Compute the Doomsday for the century year in your head.
4. Add the number of dozens of years after the century year, the remainder, and the number of fours in the remainder (again, in your head). This will give you the Doomsday of that particular year.
5. Finally, use the comprehensive Doomsday list from your memory to compute the day of the week for the particular date.
6. Ask a random person to check if you are correct.
7.Enjoy the awesome reaction from the crowd.
8. Wearing a smug face and dare someone else in the crowed to challenge you with a new random date.
9. Repeat the entire process.
10. For extra crowd-reputation, nudge the crowd to choose a date in the distant future!!
Credit and reference:J.H. Conway (recreational science article — page 28).
I hope you found this article interesting and useful. If you’d like to get notified when interesting content gets published here, consider subscribing.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-advertisement
1 year
Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Advertisement" category .
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
CookieLawInfoConsent
1 year
Records the default button state of the corresponding category & the status of CCPA. It works only in coordination with the primary cookie.
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Cookie
Duration
Description
_gat
1 minute
This cookie is installed by Google Universal Analytics to restrain request rate and thus limit the collection of data on high traffic sites.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Cookie
Duration
Description
__gads
1 year 24 days
The __gads cookie, set by Google, is stored under DoubleClick domain and tracks the number of times users see an advert, measures the success of the campaign and calculates its revenue. This cookie can only be read from the domain they are set on and will not track any data while browsing through other sites.
_ga
2 years
The _ga cookie, installed by Google Analytics, calculates visitor, session and campaign data and also keeps track of site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognize unique visitors.
_ga_R5WSNS3HKS
2 years
This cookie is installed by Google Analytics.
_gat_gtag_UA_131795354_1
1 minute
Set by Google to distinguish users.
_gid
1 day
Installed by Google Analytics, _gid cookie stores information on how visitors use a website, while also creating an analytics report of the website's performance. Some of the data that are collected include the number of visitors, their source, and the pages they visit anonymously.
CONSENT
2 years
YouTube sets this cookie via embedded youtube-videos and registers anonymous statistical data.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Cookie
Duration
Description
IDE
1 year 24 days
Google DoubleClick IDE cookies are used to store information about how the user uses the website to present them with relevant ads and according to the user profile.
test_cookie
15 minutes
The test_cookie is set by doubleclick.net and is used to determine if the user's browser supports cookies.
VISITOR_INFO1_LIVE
5 months 27 days
A cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.
YSC
session
YSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.
yt-remote-connected-devices
never
YouTube sets this cookie to store the video preferences of the user using embedded YouTube video.
yt-remote-device-id
never
YouTube sets this cookie to store the video preferences of the user using embedded YouTube video.
Comments