Examples of Lewis Carroll's algorithm for finding the day of the week


You'll need to look at the algorithm to make sense of this.

Example 1 - Day of the week for the data 23 May 1845

Take the given date in 4 portions, viz. the number of centuries, the number of years over, the month, the day of the month.
So we split our date into the 4 portions and get:

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.
We'll do each step in turn...

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.
Our date is after September 2, 1752 so we use the 'New Style'. So we take our century item which is 18 (from above). When we divide 18 by 4 we get 4 with 2 remainder. So the 'overplus' is 2. We substract that from 3 giving us 1 (3-2). And finally multiply that by 2. Giving 2 (2*1).

2 does not excede 7 so the first step is done.

The Year-item: Add together the number of dozens, the overplus, and the number of 4s in the overplus.
Our year item is 45. Since a dozen is 12 we divide 45 by 12 and get 3 with 9 remainder. So the number of dozens is 3, the overplus if 9, and the number of 4's in the overplus is 2 (9/4 gives 2 with 1 remainder). Thus our year item becomes 14 (3 + 9 + 2).

We take the previous total of 2. Add 14 to it, to get 16. 16 exceeds 7 so we divide by seven and keep the remainder only. 16 divided by 7 gives 2 with 2 remainder. So our total is 2.

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".
This is the hard bit, since the way it is worded you need to calculate based on the previous month. The simplest way to handle this is to build a table for all the months and then just use that. This is much easier if you realise that what is really being calculated is how many days have passed since January 1, on the first day of the month being calculated. We can %7 those numbers since we only care about days of the week.
MonthMonth-itemWhy that value
January0Given by the algorithm
February3Given by the algorithm
March3Given by the algorithm
April6March's value is 3. March has 31 days. 31+3 = 34. 34%7 = 6
May1April's value is 6. April has 30 days. 30+6 = 36. 36%7 = 1
June4May's value is 1. May has 31 days. 31+1 = 32. 32%7 = 4
July6June's value is 4. June has 30 days. 30+4 = 34. 34%7 = 6
August2July's value is 6. July has 31 days. 31+6 = 37. 37%7 = 2
September5August's value is 2. August has 31 days. 31+2 = 33. 33%7 = 5
October0Septermber's value is 5. September has 30 days. 30+5 = 35. 35%7 = 0
November3October's value is 0. October has 31 days. 31+0 = 31. 31%7 = 3
December5December's value is 3. November has 30 days. 30+3 = 33. 33%7 = 5
As a quick check, notice that the algorithm defines December as having a month-item value of 12. We got 5. But 12%7 = 5. So we agree on December. You can calculate a few others months the way the algorithm states to check more months if you like.

So for May we get a value of 1. We add that to our previous total and get 3 (2+1). 3 is not exceed 7 so we leave it as 3.

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).
Our year is not a leap year (and the month is not January or February) so our day-item stays as 23.

Our total is 23 + 3 = 26. 26 exceeds 7, so we change it to 26%7 = 5.

That means our date falls on Friday. A quick check of cal 5 1845 confirms that fact.


One more example : 6 February 1640

The century item is 16. We are an 'Old Style' date (pre 2/9/1752).So we do 18-16 = 2.

The year item is 40. 40/12 = 3. 40%12 = 4. 4/4 = 1. Thus we get 3+4+1 = 8.

8+2 = 10. 10%7 = 3. So our total is now 3.

The month is February, by our table abloe that gives us a value of 3.

3+3 = 6. So our total is now 6.

The day item is 6. 1640 is a leap year (Old Style so we check if divisible by 4 which it is) and the month is January or February so we subtract 1 leaving us with 5.

6+5 = 11. 11%7 = 4. So our day of the week is Thursday. Again a quick check of cal 2 1640 confirms the result.