How to tell the day of the week of any date

During my national service stint I had a friend who was very good at maths. One day, one of the sergeants wanted to test how good my friend was. He asked my friend to find out the day of the week which he will ORD (the day he ends his service) on. It took my friend approximately 10 seconds to give the answer. Not convinced, the sergeant used his phone to check and was absolutely amazed at his accuracy. Coming from a strong maths background, I of course knew how the trick was done. But to a layman, this is a very impressive trick.

Inspired by the Arthur’s Benjamin performance in this video http://www.ted.com/talks/arthur_benjamin_does_mathemagic.html and the performance of the man himself at one of the talks held at Cambridge, I decided to write this entry.

How to tell the day of the week of any date.

Most maths major would scream “modulus seven!” That is correct, it is not too difficult to figure out how it is done, but being able to perform it quickly is a skill and I’m going to talk about a way of making it easy to perform this feat.

Basic idea: (Year code + Month code + Date code) mod 7 = Day code

Year code

Year code is derived by the following formula:

(year after the base century + no. of leap years) + Century code mod 7

Century code is the sequence 5 3 1 6 5 3 1 6 … starting from 1600. (It doesn’t make sense to go before 1600 since the Gregorian calendar system was only established in 1582 and it was not adopted in England and its colonies until 1752). So year 1600 has year code 5, year 1700 has year code 3 etc. One can think about it as looking at the first 2 digit of the year and finding the remainder when divided by 4 (modulo 4), then it is easy to see remainder 0 gives year code 5, remainder 1 gives 3 etc. Another easy way to remember this is that it is the odd numbers 5, 3, 1, and the last number is just an anomaly.

Let’s now focus on the 21st century. Year 2000 has century code 5

Examples:

  • 2013: (13 + floor(13/4) + 5) = 0 mod 7
  • 1990: (90 + floor(90/4) + 6) = 6 mod 7
  • 1888: (88 + floor (88/4) + 1) = 6 mod 7

Month code

In his video, Arthur described a way to remember the month code, and I shall describe his technique.

Jan 1 Apr 0 Jul 0 Oct 1
Feb 4 May 2 Aug 3 Nov 4
Mar 4 Jun 5 Sep 6 Dec 6

Note that if one looks at the numbers down the columns, 144 = 12 square, 25 = 5 square, 36 = 6 square, 146 = 12 square + 2. While the the last number is an anomaly, it is not too difficult to remember since there is only one anomaly.

A slight complication when dealing with leap years. (A quick recap: leap years are years divisible by 4 but not divisible by 100 unless it is divisible by 400.) In a leap year, the year code of Jan and Feb is reduced by 1. (This is because of over counting in the year code as an additional 1 was added by the leap year.)

Examples:

  • June 2013: 5 + 0 = 5
  • Jan 1990: 1 + 6 = 0
  • Jan 1888: 0 + 6 = 6

Date code

This is very straight forward. It is just the remainder of the day of the month when divided by 7. (or day of the month mod 7)

Day code

This is also another straight forward calculation. Monday correspond to 1, Tuesday to 2, etc… Sunday to 0.

Putting it all together

The formula says it all.

Examples:

  • Jun 14 2013: 0 (year) + 5 (month) + 14 (day) = 5 mod 7 == Friday
  • Jan 24 1990: 6 (year) + 1 (month) + 24 (day) = 3 mod 7 == Wednesday
  • Jan 24 1888: 6 (year) + 0 (month) + 24 (day) = 2 mod 7 == Tuesday

Final remarks

Just a few tips: Asking for the year first will make things easier since that is the hardest computation you’ll need to do for this feat. Casting out seven along the way is also very useful. So when calculating the year code of 1888, we do floor(88/4) = 22. But we think of it as the number 1 instead of 22. Then when adding it to 88, just cast out seven, so 88 -> (subtract 70) -> 18 -> 4. So our year code for 1888 is just 1 + 4 + 1 (century code) = 6.

If you’re planning to do this on a specific group of people (say your friends) and you know their age range, then you can increase the speed of finding out when they are born by remembering some of the year code of those year. For example, 1992, 1993, 1994, 1995 have year code 2,3,4,5 respectively. It is easy to find out the year code this way and get the bulk of the calculation out of the way.

The numbers discussed here are chosen because I find them easy to remember. It is not too difficult to tweak the numbers to something else which may be easier for you to remember. For example, we can increase all the month code by 1 if we decrease the century code by 1.

For example

Century code 4 2 0 5

Jan 2 Apr 1 Jul 1 Oct 2
Feb 5 May 3 Aug 4 Nov 5
Mar 5 Jun 6 Sep 7 Dec 0

is also another way set of values that will work with this formula.

There is also another algorithm to determine the day of the week. It is called the doomsday method http://rudy.ca/doomsday.html. For those interested, it is useful to check it out.

Advertisements

Published by

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s