Practice mental Day of the week calculation
Corrections:
4-Nov-2019 | vs 1.2 | Redesign & Improved GUI. Fix an issue where the random date generated could return 0, which was not a valid day |
28-Dec-2017 | vs 1.1 | Improve description of the method used and minor bugs |
21-Jun-2017 | vs 1.0 | The initial release of practice mental day-of-the-week calculation |
Mental calculation of the weekday of the week for any dates
Using the techniques described below can be used as a good party trick or just a way to stimulate and keep your brain sharp.
On the internet, several methods describe different ways of achieving the same answer for the day of the week.
I find the below methods the easiest way of doing it and the fastest to learn. I first came across this method via Arthur Benjamin
(https://www.math.hmc.edu/~benjamin/ ) who is the wizard of mental math calculation
and can be found on Youtube or "The secrets of Mental Math" on www.TheGreattCourses.com
The only math you need to know is to be quick in adding 1 or 2 digits number together, memorize months and century offset and also be quick in taking a number modulus 7.
(calculating the remainder of dividing by 7, for shorthand we will use the C language operator for modulus %).
The technic is straightforward for a given day in the format DD/MM/YYYY.
Start with the year (YYYY) and for simplicity, we split up the year into a 2-digit century and a 2-digit year within the century. E.g. CCYY.
- We start with the YY and do nothing other than remember the year. This is known to be the year offset. YY
- Next, we find how many leap years we have experienced so far in this century by dividing the year by 4, taking the whole number of the year divided up in 4, and adding it to the number from step 1. E.g. For year 58 you get 58/4=14
- Next you add the century offset to the number. Here you must memorize a few numbers. For the 19th hundred, it is 0, for the 18th century it is 2, for the 17th century it is 4 and for the 16th century it is 6 and then the number sequence repeats itself both up and down
- Next step is to add the Months offset and here we need to memorize a few more numbers.
- Next step is to add a possible leap year offset only valid for the first two months (Jan and Feb). The offset is a fixed constant of -1 otherwise 0 if the months are from Mar-Dec
- Lastly, we add the day of the month´s DD to our result.
- We take all the offset we have added from step 1 to step 6 and find the remainder after dividing it by 7. The result is a number between 0 and 6 and the day of the week is as follows.
Century | 16th | 17th | 18th | 19th | 20th | 21th | 22th | 23rd |
Offset | 6 | 4 | 2 | 0 | 6 | 4 | 2 | 0 |
Months | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
Offset | 1 | 4 | 4 | 0 | 2 | 5 | 0 | 3 | 6 | 1 | 4 | 6 |
Remember | 122 | 52 | 62 | 122+ |
Arthur Benjamin cleverly suggested for each quarter, 12 squares, 5 squares, 6 squares, and a little bit more than 12 squares to remember the offset and it works out great. Easy to remember and easy to calculate. E.g. The month of September has an offset of 6 while the month of April has an offset of 0.
Result modulus 7 | Day of the Week |
0 | Saturday |
1 | Sunday |
2 | Monday |
3 | Tuesday |
4 | Wednesday |
5 | Thursday |
6 | Friday |
Let´s see how it works on a real example of let´s say September 4, 1957, 22 February 2004, and of course Albert Einstein´s birthday 14 March 1879.
Date | Offset | 04/09/1957 | 22/02/2004 | 14/03/1879 |
YY | Year offset YY | 57 | 4 | 79 |
Number of leap year | (YY/4) | 14 | 1 | 19 |
CC | Century offset (CC | 0 | 6 | 2 |
MM | Months offset (MM) | 6 | 4 | 4 |
Leap year month offset | Jan-Feb only | 0 | -1 | 0 |
DD | Day in Months (DD) | 4 | 22 | 14 |
Total | 81 | 36 | 118 | |
Result modules 7 (%) | 4=Wednesday | 1=Sunday | 6=Friday |
As always you need to practice mastering the mental calculations and the practice calculator above will help you quickly obtain your skills
to do it fast and accurately. There are some shortcuts you can apply along the way. E.g. you don´t need to wait until all the digits have been calculated
and added together to do your module 7 calculation. You can do it along the way where it makes sense. E.g. Albert Einstein´s was birthday 14/03/1879.
Notice that after the first 2 offsets, the result is 0 meaning we can forget the YY and number of leap year calculations to free up your brain
to do the remaining calculation. I usually apply this shortcut only to the first two offsets calculated to reduce the accumulated number.
The accumulated of the other offsets will be less than 43. Making it faster to do the modulus 7 calculation of the total sum at the end.
Offset | 14/03/1879 | Accumulator |
Year offset YY | 79 | 79%7=2 |
Number of leap years (YY/4) | 19 | (2+19)%7=0 |
Century offset (CC) | 2 | 2%7=2 |
Months offset (MM) | 4 | (2+4)%7=6 |
Leap year month offset | 0 | (6+0)%7=6 |
Day in Months (DD) | 14 | (6+14)%7=6 |
Total | 118 | 6 |
Result modules 7 | 6=Friday | 6=Friday |
Have fun