Sei sulla pagina 1di 3

c 

      


The algorithm is valid for the Gregorian calendar. Britain and its colonies started using the
Gregorian calendar on Thursday, September 14, 1752 (the previous day was Wednesday,
September 2). The areas now forming the United States adopted the calendar at different times
depending on the colonial power; Spain, France, Italy, and others had started using it in 1582,
while Russia still had not done so by 1867 when U.S. purchased Alaska.

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.

1. Look up the 1900s in the centuries table: 0


2. Note the last two digits of the year: 82
3. Divide the 82 by 4: 82/4 = 20.5 and drop the fractional part: 20
4. Look up April in the months table: 6
5. Add all numbers from steps 1±4 to the day of the month (in this case, 24):
0+82+20+6+24=132.
6. Divide the sum from step 5 by 7 and find the remainder: 132/7=18 remainder 6
7. Find the remainder in the days table: 6=Saturday.

Now let's try September 18, 1783.

1. Look up the 1700s in the centuries table: 4


2. Note the last two digits of the year: 83
3. Divide the 83 by 4: 83/4 = 20.75 and drop the fractional part: 20
4. Look up September in the months table: 5
5. Add all numbers from steps 1±4 to the day of the month (in this case, 18):
4+83+20+5+18=130.
6. Divide the sum from step 5 by 7 and find the remainder: 130/7=18 remainder 4
7. Find the remainder in the days table: 4=Thursday.

Let's try leap year January j, 2000

1. Look up the 2000s in the centuries table: Ä


2. Note the last two digits of the year: 44
3. Divide the 00 by 4: 0/4 = 0 and drop the fractional part: 4
4. Look up January in the months table: Ä (leap)
5. Add all numbers from steps 1±4 to the day of the month (in this case, 1):
Ä 44 4 Ä j=13.
6. Divide the sum from step 5 by 7 and find the remainder: 13/7=1 remainder 6
7. Find the remainder in the days table: 6=Saturday.

Finally, let's try June 19, 2054

1. Look up the 2000s in the centuries table: 6


2. Note the last two digits of the year: 54
3. Divide the 54 by 4: 54/4 = 13.5 and drop the fractional part: 13
4. Look up June in the months table: 4
5. Add all numbers from steps 1±4 to the day of the month (in this case, 19):
6+54+13+4+19=96.
6. Divide the sum from step 5 by 7 and find the remainder: 96/7=13 remainder 5
7. Find the remainder in the days table: 5=Friday.

Ñ    
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.

Potrebbero piacerti anche