Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
This algorithm shows how to come up with four numbers. Find the sum of these four and using
modulus to restrict the result to 0 through 6, the day of the week can be determined. Since this
algorithm uses the "zeroth" day, we can add the day of the month directly (without subtracting
1). Examples of the evaluation of this algorithm are below. The four numbers are:
1. Ñ First, we can either refer to the centuries table below or use the rule: Where
is the first two digits of the year, define .
With Sunday being day 0, these numbers are the day of the week that January 0
(December 31 of the previous year), fell on year 0 of the century, with one added to the
value when century mod 4 is 0. This corrects for the fact that the next step undercounts
the number of leap days by 1 on centuries whose first two digits are evenly divisible by 4,
such as the 21st century, where year 0 (2000) was a leap year. (See Leap year).
2. D Because there are 365 days in a common year, which is 52 weeks plus 1 day, each
year will start on the day of the week after that starting the preceding year. Each leap year
has of course one more day than a common year. Assuming we know on which day a
century starts (from above), if we add the number of years elapsed since the start of the
century, plus the number of leap years that have elapsed since the start of the century, we
get the day of the week on which the year starts. Where is the last two digits of the
year, define
3. [
We refer to the months table below to work out on which day of the week a
month starts. Notice that January starts on day 0, which is simply another way of saying
that the year and January of that year start on the same day. The months table shown
allows for leap years; other algorithms leave the correction to the end and then deduct 1
from the final figure if the month is a January or February of a leap year.
4. ÿ
[
Once we know on which day of the week the month starts, we simply
add the day of the month to find the final result (noting that as mentioned above, we've
been working with the "zeroth" day of the month as the start).
v
Now for an example of the complete algorithm, let's use April 24, 1982.
Ñ
j j
j
jj
jj
jj
[
!
"
#
$
"
j
$%
&!
'!
()&!
*&!
"
j
+
,
+#
One can add constants (modulo 7) to these three tables provided the constant you add to the a
is equal to the sum of the constants you add to the
and the
modulo 7.