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
thanks, @Borg19l71 I included my interpretation of your formulas into my gist.