I also have my own algorithm for computing the day of the week, and I think that you&#x27;re doing it the hard way.  Of course, if it works for you, no problem.<p>My technique:<p><pre><code>  day_of_week = (year_day(Y) + month_day[M] + D - leapyear(Y,M)) mod 7

  year_day(Y) = let Y&#x27; = Y-1900 (or Y-1984) in Y&#x27; + trunc(Y&#x27; &#x2F; 4)

  month_day[] = { 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }

  leapyear(Y,M) = 1 if M is Jan or Feb in a leap year, else 0
</code></pre>
The year_day() is a constant for any year; in 2016, it&#x27;s 5.  The month_day[] table is easy to memorize in an inverted form that groups all the months that start on the same of the week in non-leap years:<p><pre><code>  0: Oct, Jan

  1: May

  2: Aug

  3: Feb, Mar, Nov

  4: Jun

  5: Sep, Dec

  6: Jul, Apr
</code></pre>
And that&#x27;s it.  Today (13 Jan 2016) is 5 + 0 + 13 - 1, or 17 which is 3 mod 7, or Wed.<p>(EDITED to fix line spacing issues.)