Lewis Carroll's Algorithm
for finding the day of the week for any given date
Algoritmo di Lewis Carrol per trovare il giorno della settimana di ogni data /Altri metodi
(trova in quale giorno della settimana sei nato)
[this is from Martin Gardner's The Universe in a Handkerchief: Lewis Carroll's mathematical recreations, games, puzzles, and word plays (Science Library QA95 .G3325 1996)]

Take the given date in 4 portions, viz. the number of centuries, the number of years over, the month, the day of the month.

Compute the following 4 items, adding each, when found, to the total of the previous items. When an item or total exceeds 7, divide by 7, and keep the remainder only.

The Century-item For Old Style (which ended September 2, 1752) subtract from 18. For New Style (which began September 14) divide by 4, take overplus from 3, multiply remainder by 2.

The Year-item Add together the number of dozens, the overplus, and the number of 4s in the overplus.

The Month-item If it begins or ends with a vowel, subtract the number, denoting its place in the year, from 10. This, plus its number of days, gives the item for the following month. The item for January is "0"; for February or March, "3"; for December, "12".

The Day-item The total, thus reached, must be corrected, by deducting "1" (first adding 7, if the total be "0"), if the date be January or February in a leap year: remembering that every year, divisible by 4, is a Leap Year, excepting only the century-years, in New Style, when the number of centuries is not so divisible (e.g. 1800).

The final result gives the day of the week, "0" meaning Sunday, "1" Monday, and so on.

Examples
1783, September 18
17, divided by 4, leaves "1" over; 1 from 3 gives "2"; twice 2 is "4".
83 is 6 dozen and 11, giving 17; plus 2 gives 19, i.e. (dividing by 7) "5". Total 9, i.e. "2"
The item for August is "8 from 10", i.e. "2"; so, for September, it is "2 plus 3", i.e. "5" Total 7, i.e. "0", which goes out.
18 gives "4". Answer, "Thursday".

1676, February 23
16 from 18 gives "2"
76 is 6 dozen and 4, giving 10; plus 1 gives 11, i.e. "4".Total "6"
The item for February is "3". Total 9, i.e. "2"
23 gives "2". Total "4"
Correction for Leap Year gives "3". Answer, "Wednesday"

Dividi la data in 4 numeri: i secoli, gli anni, il mese e il giorno (oggi è il 22 Marzo 2003, quindi i numeri sono: 20 (secoli), 3 (anni), 3 (marzo), 22 (giorno).

Fai i seguenti calcoli, aggiungendo ogni volta il totale al numero precedente. Quando un calcolo dà un numero maggiore di 7, dividi per 7 e aggiungi solo il resto.

1. IL SECOLO. Se la data è precedente al 1752, sottrai i secoli a 18. Se la data è posteriore, dividila per 4, sottrai il resto da 3 e moltiplica per 2 (oggi abbiamo 20 secoli : 4 = 5; resto 0- 3 = 3; 3 x 2= 6)

2. L'ANNO. Somma il numero delle dozzine, il resto, ed il numero dei 4 nel resto (nel 2003 ci sono 0 dozzine, 3 di resto e 0 numeri 4, quindi il risultato è 3)

3. IL MESE. Sottrai il numero del mese da 10 e aggiungi il numero dei giorni del mese (Marzo è il numero 3, meno 10 fa 7, più 31 fa 38; 38 diviso 7 da un resto di 3)

4. IL GIORNO. Aggiungi il numero. Il totale finora raggiunto, deve ora essere corretto togliendo 1 (se il totale finora era 0, partiamo da 7), se si tratta di Gennaio o Febbraio di un anno bisestile. E' bisestile ogni anno divisibile per 4, eccetto gli anni di fine secolo -dopo il il1752- che hanno un numero di secoli non divisibile per 4 (per es. 1800). (nel nostro caso l'anno non è bisestile, qundi il numero da aggiungere è 22 : 7=3, resto1)

Il risultato finale da un numero che corrisponde al giorno: 0=domenica; 1=lunedi; 2=martedi; 3=mercoledi; 4=giovedi; 5=venerdi; 6=sabato

Nel nostro caso la data del 22 marzo 2003, corrsiponde al seguente numero: 6 per il secolo + 3 per l'anno + 3 per il mese + 1 per il giorno= 13; 13 : 7 = 1 con resto di 6. Il numero 6 corrisponde al sabato, come in verità è oggi, sabato 22 Marzo 2003.