Since this topic briefly came up during my “mini class reunion” at Christmas, I thought I’d post it here, too, how you can calculate a weekday in your head.
Note: modulo (short: mod) means the remainder of a division of two numbers (e.g. 15 modulo 7 = 1, because 15 = 2·7 + 1), which I will use here for the sake of brevity. The resulting values correspond to the days of the week, hence 7, of course.
We’ll use 20 Nov 2011 as an example. It won’t work without calculation and memorizing, though:
- Take the year since 1900 modulo 7. Example: 2011–1900 = 111; 111 mod 7 = 6.
Hint: You can subtract 70 for starters (or any other multiple of 7) to make it easier; the remainder of the division won’t change because of this, of course.
- Due to the leap years, you then add the integer part of one quarter of the years since 1900, in our example ⌊111:4⌋ = 27. And take the remainder of this number too: 27 mod 7 = 6.
Hint: Of course it’s 100:4 = 25 for the year 2000, which you can use as an easy-to-remember basis.
Hint: You can also calculate with -1 instead of 6, since that results in the same value in the end, thanks to modulo 7.
- For the month, you memorize this table (which denotes the variations in the weekday for the first days of the months):
Jan–Mar |
0 |
3 |
3 |
Apr–Jun |
6 |
1 |
4 |
Jul–Sep |
6 |
2 |
5 |
Oct–Dec |
0 |
3 |
5 |
In the example: 3 for November.
Hint: It’s probably easiest memorized as row 0-3-3, column 0-6-6-0 and sub-columns 1-2-3 4-5-5(!).
(I think it would work without such a table, too, but once you got it memorized, I guess it’s easier this way.)
- If the date in question is in January or February of a leap year, subtract 1. (Don’t forget!)
- Then simply add the day, in the exaple 20. Or straight away the value modulo 7, here 6.
- The sum modulo 7 then results in a value from 0 to 6, with 0 for Sunday, 1 for Monday, …, 6 for Saturday.
Our example thus results in 6+6+3+20 = 35; 35 mod 7 = 0, so 20 Nov 2011 is a Sunday.
If you used -1 instead of 6: 6-1+3-1 = 7; 7 mod 7 = 0 or -1-1+3-1 = 0.
Quite easy, isn’t it?
Photo: aidasonne – Fotolia.com