Skip to main content

Mathemagics

Doomsday rule

The Doomsday rule is an algorithm devised by John Conway to quickly calculate the weekday of any date in history. The algorithm works on the following principle:

There is a set of dates (called doomsdays), that for any year, all fall on the same day (called the anchor day of the year).

Using the anchor, we can find out the weekday for any date using simple arithmetic.

The doomsdays we need to remember in order to use the algorithm are:

MM/DDFull dateMnemonic
1/3 (1/4 for leap years)Jan 3 / Jan 4-
2/28 (2/29 for leap years)Feb 28 / Feb 29-
3/14Mar 14Pi day
4/4, 6/6, 8/8, 10/10, 12/12April 4, Jun 6, Aug 8, Oct 10, Dec 12Even months except Feb
5/9, 9/5, 7/11, 11/7May 9, Sept 5, Jul 11, Nov 79-to-5 at 7-11

Other memorable doomsdays are Jul 4 (Independence day), Oct 31 (Halloween) and Dec 26 (Boxing day).

In total, there are 52 doomsdays in a year. In leap years, the doomsdays in the month of January and February are shifted by one day. However, the total remains the same.

The algorithm involves the following steps.

  1. Find the anchor day for the century (required for step 2).
  2. Find the anchor day for the year. All doomsdays fall on this anchor day.
  3. Count forward/backward from the nearest doomsday to the specified date.

For calculations, we assign an index for each weekday. Starting from Monday (11) to Sunday (77), the index equals rankmodโ€‰โ€‰7rank\mod 7.

DayIndexMnemonic
Monday1One-day
Tuesday2Twos-day
Wednesday3Threes-day
Thursday4Fours-day
Friday5Five-day
Saturday6Sixtur-day
Sunday0None-day
Example

Jul 27, 1987

  1. Anchor day for the century (1900s) = 3 (Wednesday)

  2. Anchor day for the year (1987) = 6 (Saturday)

  3. Nearest doomsday to Jul 27 is Jul 11 = Saturday (from step 2).

    July 25 = July 11+7+7 = Saturday

    July 27 = Monday.

Finding the anchor day for the century

Given a year yy,

Let cc = the first 2 digits of the year (or โŒŠy100โŒ‹\left\lfloor\frac{y}{100}\right\rfloor)

Method 1

Anchor = 5ร—(cmodโ€‰โ€‰4)modโ€‰โ€‰75\times(c\mod 4)\mod 7 + Tuesday

Method 2

Value of cmodโ€‰โ€‰4c\mod 4Anchor
0Tuesday
1Sunday
2Friday
3Wednesday
Example

1700s

17modโ€‰โ€‰4=1โ€…โ€ŠโŸนโ€…โ€Š17\mod 4 = 1 \implies Sunday

Or

5ร—(17modโ€‰โ€‰4)modโ€‰โ€‰75\times(17\mod 4)\mod 7 + Tuesday = 55 + Tuesday = Sunday

The following table lists the anchor days for 1500s to 2600s:

CenturyAnchor day (Index)
1500s, 1900s, 2300sWednesday (3)
1600s, 2000s, 2400sTuesday (2)
1700s, 2100s, 2500sSunday (0)
1800s, 2200s, 2600sFriday (5)

Mnemonics for recent centuries:

  • 1900s: We-in-dis-day (most living people were born in that century)
  • 2000s: Twos-day or Y-Tue-K
  • 2100s: Twenty-one-day is Sunday (2100 is the start of the next century)

Finding the anchor day for the year

Given a year XXYYXXYY,

Method 1

Let aa = Anchor day of the century

b=โŒŠYY12โŒ‹b = \left\lfloor\frac{YY}{12}\right\rfloor

c=YYmodโ€‰โ€‰12c = YY\mod 12

d=โŒŠc4โŒ‹d = \left\lfloor\frac{c}{4}\right\rfloor

Anchor day of the year = (a+b+c+d)modโ€‰โ€‰7(a+b+c+d)\mod 7

Method 2

Anchor = (YY+โŒŠYY4โŒ‹)modโ€‰โ€‰7\left(YY+\left\lfloor\frac{YY}{4}\right\rfloor\right)\mod 7

Method 3: The "odd+11" method

  1. Let t=YYt = YY
  2. If tt is odd, add 1111.
  3. t=t2t = \frac{t}{2}
  4. If tt is odd, add 1111.
  5. t=7โˆ’(tmodโ€‰โ€‰7)t = 7-(t\mod 7)
  6. Count forward tt days from the century's anchor day to get the year's anchor day.
note

Each common year advances the anchor day by one day. Each leap year advances it by two days.

Example

1987

Let a=3a = 3

b=โŒŠ8712โŒ‹=7b = \left\lfloor\frac{87}{12}\right\rfloor = 7

c=87modโ€‰โ€‰12=3c = 87\mod 12 = 3

d=โŒŠ34โŒ‹=0d = \left\lfloor\frac{3}{4}\right\rfloor = 0

Anchor = (3+7+3+0)modโ€‰โ€‰7=13modโ€‰โ€‰7=6(3+7+3+0)\mod 7 = 13\mod 7 = 6 = Saturday

It can be useful to use your index, middle, and ring fingers and the pinkie to store the values for aa, bb, cc, and dd respectively during mental calculations.

Or using "odd+11" method:

8787 -> 9898 -> 4949 -> 6060 -> 7โˆ’(60modโ€‰โ€‰7)7-(60\mod 7) = 7โˆ’47-4 = 33 -> Wednesday + 3 = Saturday

Magic squares

To create a 4x4 magic square that adds upto pp, let c=pโˆ’33c = p-33 and then replace the value of cc in the following square:

1414cc121277
1111881313c+1c+1
551010c+2c+21616
c+3c+315156699

Rapid cube root

This trick relies on the fact that the cubes of single digit whole numbers end in unique digits.

03=00^3 = 0
13=11^3 = 1
23=82^3 = 8
33=273^3 = 27
43=644^3 = 64
53=1255^3 = 125
63=2166^3 = 216
73=3437^3 = 343
83=5128^3 = 512
93=7299^3 = 729

Example: Cube root of 389017389017 (AAABBCAAABBC) =73= 73

Steps:

  1. Cube just lower than AAAย (389)=343=73AAA\ (389) = 343 = 7^{3}
  2. Cube ending in Cย (7)=27=33C\ (7) = 27 = 3^{3}

Divisibility rules

NumberTestExamples
22The last digit is even0,2,40, 2, 4
33The sum of digits is divisible by 3357:3+5+7=15/3=5357: 3+5+7=15/3=5
44The last 2 digits form number that is divisible by 4732:32/4=8732: 32/4=8
55Ends in 0 or 57330,857330, 85
66Is divisible by 2 and 37272
77The alternating sum of blocks of three from right to left gives a multiple of 71,369,851:851โˆ’369+1=483=7ร—691,369,851: 851โˆ’369+1=483=7\times69
88The last three digits form a number that is divisible by 828,152:152=8ร—1928,152: 152=8\times19
99The sum of the digits form a number that is divisible by 92880:2+8+8+0=18=2ร—92880: 2+8+8+0=18=2\times9
1010The ones digit is 0270,50270, 50
1111The alternating sum of the digits is divisible by 11918,082:9โˆ’1+8โˆ’0+8โˆ’2=22=2ร—11918,082: 9โˆ’1+8โˆ’0+8โˆ’2=22=2\times11
1212Is divisible by 3 and 4336336
1313The alternating sum of blocks of three from right to left gives a multiple of 132,911,272:272โˆ’911+2=โˆ’637=13ร—โˆ’492,911,272: 272-911+2=-637=13\times-49
1414Is divisible by 2 and 7238238
1515Is divisible by 3 and 5415415

Miscellaneous

  • Sum of 10 consecutive fibonacci numbers is always equal to the 7th term in the series times 11.

    15+20+35+55+90+145+235โ€พ+380+615+99515+20+35+55+90+145+\underline\textbf{235}+380+615+995

    =235ร—11=2585=235\times11=2585