The Dying Art of Mental Math Tricks
&gt; John H. Conway is a master of mental calculations. He even invented an algorithm to calculate the day of the week for any day. He taught it to me, and I too can easily calculate that July 29 of 1926 was Thursday. This is not useful any more. If I google “what day of the week is July 29, 1926,” the first line in big letters says Thursday.<p>It takes me under 10 seconds to do that one, which is as fast or faster than opening a new window and Googling, especially on mobile, so I think this is still useful.<p>For the contribution from the year I use my own algorithm that I find faster than Conway&#x27;s algorithm. Here&#x27;s mine. In the following, assume a&#x2F;b means floor(a&#x2F;b), and odd(k) is true iff k is odd. In a C-like notation, my expression for the year contribution is<p><pre><code>   -(y&#x2F;2 - (odd(y) ? 1 : 0) - (odd(y&#x2F;2) ? 3 : 0) mod 7
</code></pre>
For example, for 26, that gives -(13 - 0 - 3) = 4. The way I would do this mentally is to note that 26 is even so I&#x27;m not going to have a subtract 1 step later, divide it by 2 to get 13, note that is odd so subtract 3 giving 10. I then do the negation mod 7 by simply noting how much I have to add to reach a multiple of 7, which in the case is 4 (10 + 4 is a multiple of 7). That gives the final result, 4.<p>My inner dialog would be &quot;26...13...10...4&quot;.<p>If we were doing year xx27, it would go like this &quot;27...13...10...9...5&quot;.<p>xx28 would go &quot;28...14...0&quot;.<p>xx29 would go &quot;29...14...13...1&quot;.<p>That illustrates all four cases.<p>I find this simpler than Conway&#x27;s method, which is (y&#x2F;12 + y + (y)&#x2F;4) mod 7, although I might find Conway&#x27;s faster if I would get off my lazy ass and memorize the multiples of 12 up to 100.<p>I also find it simpler than the odd + 11 method, which is:<p><pre><code>  T := y + (odd(y) ? 11 : 0)
  T := T&#x2F;2
  T := T + (odd(T) ? 11 : 0)
  T := -T mod 7
</code></pre>
Odd + 11 has the nice property that you only carry one number of state, whereas mine requires carrying whether the initial year was odd or even. However, it can start out increasing the number you are working with, which slows me down a little with years near the end of a century. Mine always starts out dividing by 2, and then might subtract, so is always going toward lower numbers.<p>One could remedy this in odd + 11 by changing the first step to the equivalent<p><pre><code>  T := y - (odd(y) ? 17 : 0)
</code></pre>
when dealing large y values, at the cost of having to do a -17 instead of a +11. (These are equivalent because of the 28 year cycle in the pattern of days of the week within a century. You can start off any of these Doomsday methods by adding 28 to or subtracting 28 from the year. So, if you have an odd year and subtract 28 before starting, and then add 11 under odd + 11, that is the same as subtracting 17 from the original year).<p>While I&#x27;m here, there is one other place that can use improvement. The Wikipedia article on the Doomsday rule gives the rule for calculating the century contribution when using the Julian calendar as:<p><pre><code>  6 x (c mod 7) mod 7 + 1
</code></pre>
That&#x27;s fine, but if you just blindly follow it you&#x27;ll be doing more work than you need to. It can be simplified to this simple expression:<p><pre><code>  -c + 1 mod 7
</code></pre>
For example, let&#x27;s do June 15, 1215 (date of the Magna Carta) on the Julian calendar.<p>Century component: -12 + 1 mod 7. I&#x27;d do this by noting that I have to add 2 to 12 to get a multiple of 14 (that&#x27;s the -12 part), and adding the 1, so I&#x27;d mentally just go &quot;12...2...3&quot;. The century component is 3.<p>Year component: &quot;15...7...4...3...4&quot;. Year component is 4.<p>Month component for June is 1, and day is 15 = 1, so we have 1 + 1 + 4 + 3 = 2 = Monday. For the month component, I just memorize it using Conway&#x27;s suggested mnemonics, which gives 6, but since the month component is subtracted I want the negative of that, and I use the same trick I use everywhere of simply noting what I have to add to reach a multiple of 7. 6 + 1 = 7, so that&#x27;s where the one comes from.<p>Trivia: that date is also a Monday on the Gregorian calendar.<p>A couple other things that might be useful to those wanting to play around with doing calendar calculations in your head.<p>If you want to go backwards on the year component, and find a year with year contribution M, the first year of the form 4N with year contribution M is (3M % 7)x4.<p>For example, suppose I want to know a year this century (century factor is 3 for 20xx) where Christmas falls on a Tuesday. The month contribution for December is -12 = -5 = 2. So I want 3 + M + 2 + 25 = 3 mod 7. Thus, I want M = 1. Plugging that into (3M % 7)x4 I get 12, so 2012 has Christmas on Tuesday.<p>That&#x27;s already past. I want to know upcoming years with Christmas on Tuesday. We can make use of another pattern to deal with that. The next year after Y within the same century that has the same year contribution is:<p><pre><code>   Y + 6  if Y is of the form 4N or 4N + 1
   Y + 11 if Y is of the form 4N + 2
   Y + 5  if Y is of the form 4N + 3
</code></pre>
So, starting with a year Y of the form 4N, we have these years all have the same year contribution:<p><pre><code>   Y, Y+6, Y+6+11, Y+6+11+6
</code></pre>
and then it starts over again at Y+28, which is Y+6+11+6+5.<p>Using this, and starting from 2012 (a 4N year), we get that Christmas will also be on Tuesday on 2018 (a 4N+2 year = 2012+6), 2029 (a 4N+1 year = 2018+11), and 2035 (a 4N+3 year = 2029+6), and then the 28 year cycle repeats starting at 2040 (a 4N year = 2035 + 5 = 2012 + 28).<p>An alternative to the (3M%7)x4 approach for going from M to Y is to just memorize this:<p><pre><code>  M   First Y for M
  0   0
  1   1
  2   2
  3   3
  4   9
  5   4
  6   5
</code></pre>
and use the 28 year cycle to jump up by multiples of 28 if you are interest in a Y for your M that is farther into the century, and use the 6,11,6,5 pattern to move around in shorter ranges.