A Craps Tutorial

Other Topics Section    --    Perpetual Calendars

   

For our Zeller material,   we recommend black text on a white background.
But you can try other color schemes if cookies are enabled.

 





Finding The Weekday of a Given Date

A "Reverend Zeller" Algorithm




Given a date such as 04 July 1776,
we will compute what day of the week that was.

 


 
Symbol Meaning
f Encoding number for the weekday name
(   0 = sunday   1 = monday   2 = tuesday   3 = wednesday
4 = thursday   5 = friday   6 = saturday   )
 
m nbr of the month   starting with March = 1,   April = 2,   ...   December = 10
(   Jan and Feb are the 11th and 12th months of the preceeding year.
We start with March so that extra leap year days occur at the very end of the year.   )
k day number
(   e.g.   if the date is "December 23, 1976"   then   k = 23   )
 
c and d year = 100*c + d
for example if year is 1896   then c = 18 and d = 96

 

Assumptions

The computations used to derive the formula require the assumption that the year is greater than or equal to 1600. But we also need to be sure that the date involved refers to the Gregorian calendar, which was invented in 1582 but not adopted by some countries until many years later.   The formula might not work for dates earlier than 1753.

 

A Zeller Algorithm for Computing   f

The value ( modulo 7 )   of   f   is given by

f   =   k +   2.6m - 0.2   + d +   d/4   +   c/4   -   2c

Here,   the brackets       denote a call to the
"greatest-integer" function
(   also known as the   "floor function"   or   "bracket ftn" )

  x     is the greatest integer less than or equal to x.

Examples:     47   =   47     5.9   =   5     -7.1   =   -8

Further help for those not familiar with this function:
To evaluate   -7.1   make a little sketch of part of the real number line and plot the point   -7.1.   Then consider all of the integers less than or equal to   -7.1.   There are infinitely many of them,   and they are:   -8   -9   -10   ....   Now what is the largest of these numbers ?   The answer is -8.

 

Example of How To Use   f :
Given the date   "august 4 1914",   we have
c=19
d=14
m=6   (   March is the 1st month,     August is the 6th month   )
k=4

Putting these values into the formula and reducing modulo 7 to
a number in the range 0 thru 6 yields   f = 2,
which means that   04 aug 1914   was a Tuesday.


A derivation of our formula for   f   can be found in the book
Elementary Number Theory   by   J.V. Uspensky and M.A. Heaslet
© 1939, McGraw-Hill Book Company   pages 206-211.


If you are interested in perpetual calendars,   we recommend that you also look at this
Drexel University   ask Dr. Math   web page.