The Doomsday rule was devised by John Conway in 1973 to compute the day of week in your head (https://en.wikipedia.org/wiki/Doomsday_rule). Others have made improvements for easier mental calculation.
Currently, the simplest one is published in 2023 in the paper "A Simple Formula for Doomsday" by Hirofumi Nakai (https://thatsmaths.com/2023/06/22/a-simple-formula-for-the-weekday/).
- split the year into century part and the remaining 2-digit part:
Y = 100c + y - compute the modulo 4 of these 2 parts:
c₄ = c % 4,y₄ = y % 4 - the Doomsday would be
(5(c₄ + y₄ - 1) + 10y) % 7
I made some improvements to make it even easier.
(5(c₄ + y₄ - 1) + 10y) % 7
= (5(c₄ + y₄ - 1) + 10y - 14y - 7(c₄ + y₄ - 1)) % 7
= (-2(c₄ + y₄ - 1) - 4y) % 7
= 2(1 - c₄ - y₄ - 2y) % 7
Since y has 2 digits y = 10a + b, we can quickly compute 2y % 7
2y % 7
= (20a + 2b) % 7
= (20a + 2b - 21a) % 7
= (2b - a) % 7
Replace 2y with this, we have a new formula which I named HNI (Hirofumi Nakai Improved)
2(1 - c₄ - y₄ + a - 2b) % 7
The above formulas are simple, but not so quick. If you want to calculate faster, you should memorize some values. For more detail, see https://worldmentalcalculation.com/how-to-calculate-calendar-dates/
The calculation of Doomsday contains 2 parts: W = (C + Y) % 7
Cis based on the century part:C = (2 - 2c₄) % 7Yis based on the year part:Y = 2(a - 2b - y₄) % 7
You can memorize the values for C = m2053(c₄) = (2 - 2c₄) % 7:
| c₄ | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| (2-2c₄)%7 | 2 | 0 | 5 | 3 |
Don't worry! There are only 4 alternating values for C:
C=2with year 1600s / 2000s / 2400s …C=0with year 1700s / 2100s / 2500s …C=5with year 1800s / 2200s / 2600s …C=3with year 1900s / 2300s / 2700s …
The remaining part you have to calculate is Y = 2(a - 2b - y₄) % 7.
These numbers are quite small, so you can do it quickly with some practise.
You can also add or subtract 7/14/21/... to make intermediate value even smaller.
Using the notation b₄ = b % 4, we can make it faster:
- if a is even,
y₄ = b₄ = (b-4)₄ = (b-8)₄(you can subtract 4 or 8 instead of dividing by 4) - if a is odd,
y₄ = (b+2)₄ = (b-2)₄ = (b-6)₄(you can subtract 2 or 6 instead of dividing by 4)
Y = 2(a - 2b - y₄) % 7
= (2a - 4b - 2y₄) % 7
= (2a + 3b - 2y₄) % 7
= (2a + b + 2(b - y₄)) % 7
when a is even, 10a % 4 = 0, thus y₄ = b₄
= (2a + b + 2(b - b₄)) % 7
= (2a + b + 2(4(b/4))) % 7
= (2a + b + b/4) % 7
when a is odd, 10a % 4 = 2, thus y₄ = (b+2)₄
= (2a + b + 2(b - (b+2)₄)) % 7
= (2a + b + 2(b+2 - (b+2)₄) - 4) % 7
= (2a + b + 2(4((b+2)/4)) - 4) % 7
= (2a + b + (b+2)/4 - 4) % 7
= (2a + b + (b+10)/4 - 6) % 7
= (2a + b + (10+b)/4 + 1) % 7
Now, Y requires only simple math with a and b, the 2 digits of y.
You can also memorize values of b/4 and (10+b)/4+1 to save time.
| b | 0..3 | 4..7 | 8,9 |
|---|---|---|---|
| b/4 | 0 | 1 | 2 |
| b | 0,1 | 2..5 | 6..9 |
|---|---|---|---|
| 10+b | 10,11 | 12..15 | 16..19 |
| (10+b)/4+1 | 3 | 4 | 5 |
Instead of memorization, we can simplify the formula
when a is odd (using p as the 9-complement of b p = 9 - b)
= (2a + b + (b+2)/4 - 4) % 7
= (2a + b - 2 + (b+2-8)/4) % 7
= (2a + b - 9 + (b-9+3)/4) % 7
= (2a - (9-b) + (-p+3)/4) % 7
= (2a - p - p/4) % 7
This is similar to the formula when a is even (with -p in the place of 'b')
Y = (y + y/4) % 7
= (10a + b + (10a+b)/4) % 7
= (3a + b + 2a + (2a+b)/4) % 7
= (b - 2a + (b+2a)/4) % 7
= (b - a + (b-2a)/4) % 7
if you don't mind some multiplication, we can make it shorter:
= ((5b - 6a)/4) % 7
= ((5(b-a) - a)/4) % 7
Y = (y + y/4) % 7
= (y₄ + 4(y/4) + (y/4)) % 7
= (y₄ - 2(y/4)) % 7
= (y₄ - 4(y/4)/2) % 7
= (y₄ - (y-y₄)/2) % 7
= (y₄ - (10u+v)/2) % 7
= (y₄ - 5u - v/2) % 7
= (y₄ + 2u - v/2) % 7
Here we assumed that that y-y₄ = 10u + v (v is even because (y-y₄) % 4 = 0)
Thanks to Miroslav (@Borg19l71) for sharing prior art research. There are many other formulas. You can see more at https://qr.ae/pCX9gy
Memorization for all parts of date (day, month, year, century) https://davecturner.github.io/2021/12/27/doomsday-rule.html
=2(1 - c₂ - y₂ + u - 2v) (span 66)(6 steps) can be written as
=2(u+v+c₂'+y₂')+v
(span 57)(6 steps) where c₂',y₂' are analogs of negative moduli where counting is upward and not downward like in common modulo operation.
(only one multiplication, without subtraction, no negative numbers)
Analogs of negative modulo:
Instead of normal modulo4=m4=0123 (count downward 0..3 steps until number divisible by 4)
analog of negative modulo4 gives=4-m4=4321 (count upward 1..4 steps (at least one step) until number divisible by 4)
Span is 2x(2x(9+3))+9=4x12+9=48+9=57
Example: 1979=> 2(7+9+1+1)+9=2*(18-14)+9=24+9=17=17-14=3
Example: 2000=> 2(0+0+4+4)+0=28=16=16-14=2
https://qr.ae/pCX9gy (one of my contributions)
-c2,-y2 can be calculated as "opposite modulo"=4's complement of modulo by counting upward instead downward like for common modulo
-2v can be accounted by calculating with 9's complement of v: -2v<=>2v'=2(9-v) and changing anchor value:
f(c, y)=2(u+2v'+c2'+y2')-1 where v'=9-v
v',c2',y2'=analogs of negatives of v,c2,y2 (just count upward instead of downward)
For analog of negative modulo: count at least one! (c2',y2' must yield 1..4)
Example: Analog of -11%4=-3 is counting from 11 upward (at least once): 12=>once=1
It's not equal, only analog=equal to a constant shift
Anchor value (like for year 2000) is 2(0+29+4+4)-1=226-1=51=51-49=2 (for Doomsday method)
Span is 2*(9+29+3+3)=2(27+6)=66
(Function with values ranging from min to max has span=max-min)
(Span is the measure of result spreading interval which is loosely correlated with complexity of function)
(mod7 operations are not included in calculation of span)
Common part of formula is century term
f(c)=2-c2=2+2c2'=2(1+c2')=2053(c2) (function of c2 with values 2,0,5,3)
Other part is f(y): (some examples) (there are more than 20 formulas)
f(y)=
=2(u-2v-y2) span 60 steps 5
=2(u+2v'+y2') span 60 steps 5
=y2-(y-y2)/2 span 51 steps 4
=y2+
[2u-v/2](y-y2) span 24 steps 4 where [2u-v/2] is function of y-y2=2u-v/2+0134(y2) span 26
which can be memorized with 2x10 tables
0246 1350 24 or 02461 35024
0066 5544 33 or 00665 54433
and mnemonic 0134 for y mod 4 part
(and mnemonic 2053 for c mod 4 part)
(custom anchor values can be incorporated by changing these short mnemonics if needed)
=2u-v/2+y2+y2/2 span 26
Simplest formulas for year in century part have 4..5 steps with shortest span =15 (does not mean it is the simplest)
f(y)=2u+v+00001111223344445555(y%20) span 32
f(y)=x+f(n4(x)) span 9 steps 4
where x=y%28 n4(x)=x-x%4=4n f(4n)=0,+1,-5,-11,-10,-16,-22,-28,-27 n=0..8
and %28=do nothing or -30+2 or -60+4 or -90+6