What day of the week?
What day of the week was I born? Getting a calendar of that year could prove an impossible task, although if you are in front of a computer, there are *nix
utilities that will do that for you. But seriously, who has access to a computer with unix
or linux
when the question pops?
There is a neat algorithm that, without the aid of pen and paper, will let you find the day of the week for any given date. It only takes six simple steps. On each of the first five steps, you come up with a different coefficient. In the last step, you add all those coefficients together and perform a very simple operation that offers a number between zero and six. This number indicates the day of the week:
The CENTURY step.
The century coefficient, which we denote \( C \), is computed from the first two digits of the year. The coefficient for 20 is “minus one”, and for any other century, you can obtain the coefficient from the following table:
For example, the first two digits of 1973 are 19: the corresponding coefficient is \( C=0. \)
The YEAR step.
The year coefficient, which we denote \( Y \), is computed from the last two digits of the year as the output of the following formula: if \( x \) is the last two digits of the year, then \( Y = x + \lfloor \frac{x}{4} \rfloor, \) where \( \lfloor \cdot \rfloor \) indicates the integer part of any given real number.
For example, the last two digits of 1973 are 73. Since \( 73 = 4 \times 18+3, \) the year coefficient is \( Y = 73 + 18 = 91.\)
The MONTH step.
This is the part that takes some memorizing. The month coefficient is given by the table below. Lewis Carroll gave a very nice rule to construct that table:
For example, August has a two in the table. The month coefficient is thus \( M = 2.\)
The LEAP YEAR step.
Every year whose two last digits are a multiple of four is a leap year (except if those two digits are both zero—in that case, leap year occurs only if the whole year is a multiple of four-hundred). In case of leap year and the month being either January or February, we subtract one. Otherwise, zero.
For example, 1973 is not a leap year, so the coefficient is \( L=0.\)
The DAY step.
The corresponding coefficient \( D \), is simply the day of the month.
For August 22, the coefficient is \( D = 22.\)
Final Step.
In the final step, we add up all the previous coefficients, and compute the remainder after division by seven (this is equivalent to add or subtract seven as many times as necessary so we obtain a number between zero and six). This indicates the day of the week, by the easy correspondence Sunday is zero, Monday is one, and so on.
For example, for August 22, 1973, we have
\begin{equation} C + Y + M + L + D = 0 + 91 + 2 + 0 + 22 = 115 = 7 \times 16 + 3. \end{equation}
The remainder is thus 3, and the day of the week is Wednesday.
Miscellaneous
With the help of the libraries calendar
and folding
of the \( LaTeX \) package tikz
, it is possible to generate this fun calendar printed on an unfolded dodecahedron. The code could not be simpler:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
\sffamily\scriptsize
\begin{center}
\begin{tikzpicture}[transform shape,
every calendar/.style= {at={(-8ex,4ex)}, week list, month label above centered,
month text=\bfseries\textcolor{red}{\%mt} \%y0,
if={(Sunday) [black!50]} }]
\tikzfoldingdodecahedron [folding line length=2.5cm,
face 1={ \calendar [dates=\the\year-01-01 to \the\year-01-last];},
face 2={ \calendar [dates=\the\year-02-01 to \the\year-02-last];},
face 3={ \calendar [dates=\the\year-03-01 to \the\year-03-last];},
face 4={ \calendar [dates=\the\year-04-01 to \the\year-04-last];},
face 5={ \calendar [dates=\the\year-05-01 to \the\year-05-last];},
face 6={ \calendar [dates=\the\year-06-01 to \the\year-06-last];},
face 7={ \calendar [dates=\the\year-07-01 to \the\year-07-last];},
face 8={ \calendar [dates=\the\year-08-01 to \the\year-08-last];},
face 9={ \calendar [dates=\the\year-09-01 to \the\year-09-last];},
face 10={\calendar [dates=\the\year-10-01 to \the\year-10-last];},
face 11={\calendar [dates=\the\year-11-01 to \the\year-11-last];},
face 12={\calendar [dates=\the\year-12-01 to \the\year-12-last];}
];
\end{tikzpicture}
\end{center}