Doomsday Algorithm - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Math Apps : Computer Science : MathApps/DoomsdayAlgorithm

Doomsday Algorithm

Main Concept

Have you ever wondered what day of the week a particular date fell on? What would you do if you didn't have access to a calendar? The Doomsday Algorithm is a method developed by John Conway to find the day of the week of any given date based on a perpetual calendar. In any given year, there are certain easy-to-remember 'special' dates that all happen to occur on the same day of the week. That day of the week is called the doomsday for that year, and the corresponding dates are called special doomsday dates. The doomsday can be easily calculated starting from the given year. Then you can simply compare the current date with the nearest (or any) 'special' date to determine the current day of the week:

1. 

Find the doomsday of the year using the doomsday algorithm. This involves first finding an anchor day for the century, then using the last two digits of the century to find the number of days (x) that the anchor day must be shifted by to determine the doomsday for the year.

2. 

Find the closest special doomsday date, one of a number of easy to remember dates that falls on the doomsday of the year.

3. 

Figure out the shift between the current date and the closest special date, then apply that same shift to the doomsday to find the current day of the week.

 

From this point on, the days of the week will be used interchangeably with the integers modulo 7 using the following table:

 

Sunday

Monday

Tuesday

Wednesday

Thursday

Friday

Saturday

0

1

2

3

4

5

6

 

Finding the Anchor Day of the Century

The Gregorian Calendar, also the internationally accepted calendar of today, has the following scheme:

• 

The cycle of the calendar repeats itself every 400 years.

• 

A common year consists of 365 days, while a leap year consists of 366 days (the leap day or added day being February 29).

• 

A leap year occurs every year denoted by a multiple of four, except for multiples of 100 that are not multiples of 400. For example, the years 1700, 1800 and 1900 are not leap years, while the year 2000, the fourth centennial in the series, is a leap year. Therefore, in a Gregorian cycle, or 400 years, there are 303 common years and 97 leap years. This is to accommodate for the fact that a solar year is slightly shorter than 365.25 days, it is 365.2425 days.

Taking all of the above into account, the anchor day for a given year is defined as:

Anchor  = 5  flooryear100 mod 4 + Tuesday

Note: The floor of a number z, also denoted  z, is the greatest integer smaller than z. In other words, the floor function rounds a number down to the preceding integer.

Finding the Doomsday of the Year

There are multiple methods to finding the doomsday of a year. All three methods mentioned use the common variables:

• 

Let y represent the last two digits, taken collectively, of the given year's date.

• 

Let x be the number of days to be added to the anchor day, between the anchor day and the doomsday.

Method 1

1. 

Add y to integer quotient, or floor, of y divided by 4.

2. 

Divide the sum by 7, a is the remainder of this process.

x   =  y + y4 mod 7

 

Method 2

1. Let a to be the floor of y12.

2. Let b to be the modulus of y12.

3. Let c be the floor of b4.

4. x is the modulus of a + b+ c7.

 a  =   y12;   b  =  y mod 12;  c  =  b mod 4x  =  y12 + y mod 12 + y mod 124  mod 7    =  a + b + c mod 7

Method 3

1. Let x  =  y.

2. If x is odd, add 11 to it.

3. Divide x by 2.

4. If x is odd again, add 11 to it.

5. Subtract the modulus of x by 7 from 7.

x   =   y + 11 y mod 22 + 11y + 11y mod 22mod 2 mod 7

 

Shift the anchor day by x to obtain the doomsday.

Finding the Closest Special Doomsday Date to the Given Date

The following is a table of special doomsday dates for any given year, along with a simple mnemonic for remembering them. The current step involves just choosing one of these that is relatively close to the given date.

 

Special Doomsday Dates

 

 

Date(s)

Mnemonic

 

 

4/4, 6/6, 8/8, 10/10, 12/12

Dates in the form n/n, where n is an even number between 4 and 12

 

 

5/9, 9/5, 7/11, 11/7

"I work from 9 to 5 at 7-11"

 

 

Feb 28/29 or 'March 0'

Last Day of February

 

 

March 14

Pi Day

 

 

October 31

Halloween

 

 

Finding the Day of the Given Date

The day of the given date is determined by simply adding to the year's doomsday, the same shift that separates the current date and one of the special doomsday dates in the above table.

 

Explore by entering different dates and choosing from the various algorithms.

Month

Day

Year

 

Anchor Day  :

 

Doomsday   :

 

Actual Date :

More MathApps

MathApps/ComputerScience