My favorite mathematical party trick is to tell people the day of the week they were born, given their birthday information. For example, if someone told you that she was born on May 2, 2002, you can instantly tell her that she was born on a Thursday. An even more practical skill is the ability to figure out the day of the week for any date of the current
or upcoming year. I will teach you an easy method to do this, and the mathematics behind it, in this section.
But before we delve into the method, it’s worth reviewing some of the scientific and historical background behind the calendar. Since the Earth takes about 365.25 days to travel around the Sun, a typical year has 365 days, but we add a leap day, February 29, every four years.
(This way, in four years, we have 4×365+1 = 1461 days, which is just about right.) This was the idea behind the Julian calendar, estab-lished by Julius Caesar more than two thousand years ago. For ex-ample, the year 2000 is a leap year, as is every fourth year after that:
2004, 2008, 2012, 2016, and so on, up through 2096. Yet 2100 will not be a leap year. Why is that?
The problem is that a year is actually about 365.243 days (about eleven minutes less than 365.25), so leap years are ever so slightly over-represented. With four hundred trips around the Sun, we experience 146,097 days, but the Julian calendar allocated 400×365.25 = 146,100 days for this (which is three days too long). To avoid this problem (and other difficulties associated with the timing of Easter) the Gregorian cal-endar was established by Pope Gregory XIII in 1582. In that year, the Catholic nations removed ten days from their calendar. For example, in Spain, the Julian date of Thursday, October 4, 1582, was followed by the Gregorian date of Friday, October 15, 1582. Under the Gregorian cal-endar, years that were divisible by 100 would no longer be leap years, unless they were also divisible by 400 (thus removing three days). Con-sequently, 1600 remained a leap year on the Gregorian calendar, but 1700, 1800, and 1900 would not be leap years. Likewise, 2000 and 2400 are leap years, but the years 2100, 2200, and 2300 are not leap years.
Under this system, in any four hundred year period, the number of leap years is 100−3 = 97 and therefore the number of days would be (400×365) +97=146, 097 as desired.
The Gregorian calendar was not accepted by all countries right away, and the non-Catholic countries were particularly slow to adopt it. For example, England and its colonies didn’t make the switch until 1752, when Wednesday, September 2, was followed by Thursday, September 14. (Notice that eleven days were eliminated, since 1700 was a leap year on the Julian calendar but not in the Gregorian calendar.) It was not until the 1920s that all countries had converted from the Julian to the Gregorian calendar. This has been a source of complications for his-torians. My favorite historical paradox is that both William Shakespeare and Miguel de Cervantes died on the same date, April 23, 1616, and yet
they died ten days apart. That’s because when Cervantes died, Spain had converted to the Gregorian calendar, but England was still on the Julian calendar. So when Cervantes died on Gregorian April 23, 1616, it was still April 13, 1616, in England, where Shakespeare was living (if only for ten more days).
The formula to determine the day of the week for any date on the Gregorian calendar goes like this:
Day of Week≡Month Code + Date + Year Code (mod 7)
and we will explain all of these terms shortly. It makes sense that the formula uses modular arithmetic, working mod 7, since there are 7 days in a week. For example, if a date is 72 days in the future, then its day of the week will be two days from today, since 72 ≡2(mod 7). Or a date that is 28 days from today will have the same day of the week, since 28 is a multiple of 7.
Let’s start with the codes for the days of the week, which are easy to memorize.
Number Day Mnemonic
1 Monday 1-day
2 Tuesday 2s-day
3 Wednesday raise 3 fingers
4 Thursday 4s-day
5 Friday 5-day
6 Saturday 6er-day
7 or 0 Sunday 7-day or none-day
I have provided mnemonics to go along with each number-day pair, most of which are self-explanatory. For Wednesday, notice that if you raise three fingers on your hand, you create the letter W. For Thursday, if you pronounce it as “Thor’s Day,” then it will rhyme with “Four’s Day.”
Aside
So where do the names of the days of the week come from? The cus-tom of naming the days of the week after the Sun, the Moon, and the five closest heavenly bodies dates back to ancient Babylonia. From the Sun, the Moon, and Saturn, we immediately get Sunday, Monday, and Saturday. Other names are easier to see in French or Spanish. For in-stance, Mars becomes Mardi or Martes; Mercury becomes Mercredi or Mi´ercoles; Jupiter becomes Jeudi or Jueves; Venus becomes Vendredi or Viernes. Note that Mars, Mercury, Jupiter, and Venus were also the names of Roman gods and goddesses. The English language has Ger-manic origins and the early Germans renamed some of these days for Norse gods. So Mars became Tiw, Mercury became Woden, Jupiter be-came Thor, and Venus bebe-came Freya, and that’s how we arrived at the names for Tuesday, Wednesday, Thursday, and Friday.
The month codes are given below, along with my mnemonics for remembering them.
Month Code Mnemonic
January* 6 W-I-N-T-E-R
February* 2 Month number 2
March 2 March 2 the beat!
April 5 A-P-R-I-L or F-O-O-L-S
May 0 Hold the May-O!
June 3 June B-U-G
July 5 Fiver-works in the sky!
August 1 August begins with A = 1
September 4 Beginning of F-A-L-L
October 6 T-R-I-C-K-S (rhymes with 6)
November 2 2 pieces of 2rkey!
December 4 L-A-S-T or X-M-A-S
*Exception: In leap years, January=5 and February=1
I’ll explain how these numbers are derived later, but I want you to first learn how to perform the calculation. For now, the only year code you need to know is that 2000 has year code 0. Let’s use this information to determine the day of the week of March 19 (my birthday) that year.
Since March has a month code of 2, and 2000 has a year code of 0, then our formula tells us that March 19, 2000, has
Day of Week=2+19+0=21≡0 (mod 7) Therefore, March 19, 2000, was a Sunday.
Aside
Here is a quick explanation of where the month codes come from. Notice that in a non-leap year, the month codes for February and March are the same. That makes sense, because when February has 28 days, then March 1 is 28 days after February 1, and so both months will begin on the same day of the week. Now as it happens, March 1, 2000, was a Wednesday. So if we want to give 2000 a year code of 0 and we want to give Monday a day code of 1, then that forces the month code for March to be 2. Thus, if it’s not a leap year, then February must have a code of 2 too! And since March has 31 days, which is 3 greater than 28, then the April calendar is shifted 3 days further, which is why it has a month code of 2+3 =5. And when we add the 28+2 days of April to the month code of 5, we see that May must have month code 5+2=7, which can be reduced to 0 since we are working mod 7. Continuing this process, we can determine the month codes for the rest of the year.
On the other hand, in a leap year (like 2000), February has 29 days, so the March calendar will be one day ahead of February’s calendar, which is why the month code for February is 2−1 = 1 in a leap year.
January has 31 days, so its month code must be 3 below the month code for February. So in a non-leap year, the month code for January will be 2−3= −1≡6(mod 7). In a leap year, the month code for January will be 1−3= −2≡5(mod 7).
What happens to your birthday as you go from one year to the next?
Normally, there are 365 days between your birthdays, and when that happens, your birthday advances by one day because 365 ≡1(mod 7), since 365 = 52×7+1. But when February 29 appears between your birthdays (assuming you weren’t born on February 29 yourself), then your birthday will advance by two days instead. In terms of our for-mula, we simply add 1 to the year code each year, except in leap years, when we add 2 instead. Here are the year codes for years 2000 through 2031. Don’t worry. You will not need to memorize this!
Notice how the year codes begin 0, 1, 2, 3, then at 2004 we leap over the 4 for a year code of 5. Then 2005 has year code 6, and 2007 should have year code 7, but since we are working mod 7, we simplify this number to 0. Then 2007 has year code 1, then 2008 (a leap year) has
Year Code Year Code Year Code Year Code
2000* 0 2008* 3 2016* 6 2024* 2
2001 1 2009 4 2017 0 2025 3
2002 2 2010 5 2018 1 2026 4
2003 3 2011 6 2019 2 2027 5
2004* 5 2012* 1 2020* 4 2028* 0
2005 6 2013 2 2021 5 2029 1
2006 0 2014 3 2022 6 2030 2
2007 1 2015 4 2023 0 2031 3
Year codes from 2000 through 2031 (* denotes leap year)
year code 3, and so on. Using the table, we can determine that in 2025 (the next year which will be a perfect square), Pi Day (March 14) will be on
Day of Week=2+14+3=19≡5 (mod 7) =Friday
How about January 1, 2008? Note that 2008 is a leap year, so the month code for January will be 5 instead of 6. Consequently, we have
Day of Week=5+1+3=9≡2 (mod 7) =Tuesday
Notice that when you read across each row in the table, as we gain 8 years, our year code always increases by 3(mod 7). For instance, the first row has 0, 3, 6, 2 (where 2 is the same as 9(mod 7)). That’s because in any 8-year period, the calendar will always experience two leap years, so the dates will shift by 8+2=10≡3(mod 7).
Here’s even better news. Between 1901 and 2099, the calendar will repeat every 28 years. Why? In 28 years, we are guaranteed to expe-rience exactly 7 leap years, so the calendar will shift by 28+7 = 35 days, which leaves the day of the week unchanged, since 35 is a mul-tiple of 7. (This statement is not true if the 28-year period crosses 1900 or 2100, since those years are not leap years.) Thus by adding or sub-tracting multiples of 28, you can turn any year between 1901 and 2099 into a year between 2000 and 2027. For example, 1983 has the same year code as 1983+28=2011. The year 2061 has the same year code as 2061−56=2005.
Thus, for all practical purposes, you can convert any year into one of the years on this table, and these year codes can be calculated pretty eas-ily. For example, why should 2017 have a year code of 0? Well, starting in 2000, which has a year code of 0, the calendar has shifted 17 times plus an additional 4 times to account for the leap years of 2004, 2008, 2012, and 2016. Hence the year code for 2017 is 17+4 = 21 ≡ 0(mod 7). How about 2020? This time we have 5 leap-year shifts (including 2020) so the calendar shifts 20+5 = 25 times, and since 25≡4(mod 7), the year 2020 has a year code of 4. In general, for any year between 2000 and 2027, you can determine its year code as follows.
Step 1: Take the last two digits of the year. For example, with 2022, the last two digits are 22.
Step 2: Divide that number by 4, and ignore any remainder. (Here, 22÷4=5 with a remainder of 2.)
Step 3: Add the numbers in Steps 1 and 2. Here, 22+5=27.
Step 4: Subtract the biggest multiple of 7 below the number in Step 3 (which will either be 0, 7, 14, 21, or 28) to obtain the year code. (In other words, reduce the number in Step 3, mod 7.) Since 27−21=6, then the year code for 2022 is 6.
Note that Steps 1 through 4 will work for any year between 2000 and 2099, but the mental math is usually simpler if you first subtract a multiple of 28 to bring the year between 2000 and 2027. For example, the year 2040 can be first reduced to 2012, then Steps 1 through 4 produce a year code of 12+3−14=1. But you can also work directly on 2040 to obtain the same year code: 40+10−49=1.
The same steps can be applied to years outside of the 2000s. The month codes do not change. There is just one little adjustment for the year codes. The year code for 1900 is 1. Consequently, the codes from 1900 through 1999 are exactly one larger than their respective codes from 2000 through 2099. So since 2040 has a year code of 1, then 1940 will have a year code of 2. Since 2022 has a year code of 6, then 1922 will have a year code of 7 (or, equivalently, 0). The year 1800 has a year code of 3, 1700 has a year code of 5, and 1600 has a year code of 0. (In fact, the calendar will cycle every 400 years, since in 400 years it will have exactly 100−3=97 leap years and so 400 years from now, the calendar will shift 400+97 =497 days, which is the same as today, since 497 is a multiple of 7.)
What day of the week was July 4, 1776? To find the year code for 2076, we first subtract 56 and then compute the year code for 2020: 20+ 5−21 = 4. Thus the year code for 1776 is 4+5 = 9 ≡ 2 (mod 7).
Therefore, on the Gregorian calendar, July 4, 1776, has
Day of Week=5+4+2=11≡4 (mod 7) =Thursday
Perhaps the signers of the Declaration of Independence needed to pass legislation quickly before the long holiday weekend?
Aside
Let’s end this chapter with another magical property of the number 9. Take any number that has different digits, written from smallest to largest. Such numbers include 12345, 2358, 369, or 135789. Multiply this number by 9 and add the digits. Although we expect the sum to be a multiple of 9, it is quite surprising that the sum of the digits will always be exactly 9. For instance,
9× 12345=11,105 9× 2358=21,222 9× 369=3321 It even works if digits are repeated, as long as the number is written from smallest to largest and the ones digit is not equal to the tens digit.
For example,
9× 12223=110,007 9× 33344449=300,100,041
So why does this work? Let’s see what happens when we multiply 9 by the number ABCDE, where A ≤ B ≤ C ≤ D < E. Since multi-plying by 9 is the same as multimulti-plying by 10−1, this is the same as the subtraction problem
A B C D E 0
− A B C D E
If we do the subtraction from left to right, then since B≥ A and C≥ B and D≥C and E>D, this becomes the subtraction problem
A (B-A) (C-B) (D-C) (E-D) 0
− E
A (B-A) (C-B) (D-C) (E-D-1) (10 - E) and the sum of the digits of our answer is
A+ (B− A) + (C− B) + (D− C) + (E− D − 1) + (10− E) =9
as desired.