I am sure there are multiple ways to do this, however I’d like to share with you this “algorithm” to find the week day of a date in the 20th century.

It involves much modular arithmetic, couldn’t be otherwise.

I’ve devised it this morning, btw…

The 2 main problems are: months, which have a “random” number of days in them, and the leap years.

The base point is that 01/01/1900 was a Monday (easy, first day of century, first day of week)

However… the calculation in split into 2 main parts. I called them DATE and LEAP.

DATE is further split into Y, M, D (obvious meaning).

Year:

You have to get the reminder of the division by 7. E.g. 36 mod 7 = 1. Keep that number.

That number will advance the day of the week. Count the years from 1900.

E.g. 1936 --> 36

Months:

let’s write them and the reminders of the number of days in that month by 7.

J F M A M J J A S O N D

3 0 3 2 3 2 3 3 2 3 2 3

Then we “sum” cumulatively the reminders (and take always the reminder)

J F M A M J J A S O N D

0 3 3 6 1 4 6 2 5 0 3 5

You have to memorize that table, using some mnemonic trick (you know well which), and use it

as a look up table. There’s no shortcut to it. Keep that number.

Day:

Keep the reminder of the day divided by 7. Take away 1.

E.g. 8… 8 mod 7 = 1. Take away 1 --> 0.

Why take away 1 ? Because the day in the date should begin by zero. The first day of the month should be 0. But it’s actually 1, so take away 1.

Watch: 0 take away 1 --> 6. Always use modular arithmetic.

Leap years:

every leap year is a day more in the year, the day of the week will advance by one.

Divide the year (counting from 1900) by 4.

Take the whole part e.g. 7 / 4 = 1.

Take the reminded by 7.

Take away 1 if the month is Jan or Feb itself.

Note: 1900 is not a leap year, because it’s a secular year.

Sum all the numbers collected. Always take the reminder by 7. Advance Monday to get the day of the week. E.g. Monday advanced 5 is Saturday.

Example:

1973 march 17

1973 --> 73 --> 73 / 7 => 3

march --> 3

17 --> 17 / 7 => 3, take away 1 => 2

leaps: 73 /4 = 18 --> 18 mod 7 => 4

3+3+2+4 = 12 --> 12 mod 7 = 5

Monday + 5 = Saturday…

It looks a daunting task but it’s not really. With some exercise you should be able to get the day in less than 1 minute, with mental calculation.

Or if you are Kim Peek, you don’t need all that.