Article | Talk | Edit | History  

Doomsday rule

From the World Wide Wiki

Our god's the fun god! Our god's the sun god! Ra! Ra! Ra!

Jump to: navigation, search

The doomsday rule is a way to calculate what day of the week any given day in the Gregorian calendar falls on. It was created by John Conway, also famous for his Game of Life cellular automaton.

Contents

Finding days of the week from other dates

Using the doomsday rule relies on finding the so-called doomsday for a year, for which there is a relatively simple formula that can quickly be done mentally (with a little practice). The doomsday is just one particular day of the week that has useful properties during that year.

This all comes from the fact that any two dates from March through December (inclusive) of the same year always have a fixed number of days between them, regardless of the year. The is pretty obvious right? If we exclude February, then a given month always has the same number of days from year to year, and the months are always in the same order from year to year. So for instance, March 4th always comes 3 days after March 1st (we don't count the first date in the pair, March 1st, because we specifically said after: So we have March 2nd, is one day after March 1st, March 3rd is two days after March 1st, and March 4th is three days after March 1st). March always has 31 days, so April 1st is always 31 days after March 1st. You can do this for any two dates in any given year, as long as you don't use January or February (these require special attention because of leap years).

A fixed number of days means a fixed number of whole weeks, with a fixed number of days remaining. So for instance, March 8th is always exactly 1 week after March 1st. That means they fall on the same day of the week (go ahead, try it out: if March 1st is on Friday, for instance, then the second is on Saturday the 3rd is on Sunday, 4th on Monday, 5th on Tuesday, 6th on Wednesday, 7th of Thursday, and the 8th brings us back to Friday). March 9th, on the other hand, is always exactly 8 days after March 1st, which is 1 full week, plus one more day. Another way of looking at it is that March 9th always falls one day later than March 8th, which always falls on the same day as March 1st. Therefore, March 9th always falls one week day later than March 1st. So, for instance, if March 1st is on Friday, March 9th is on a Saturday. If March 1st is a Saturday, March 9th is a Sunday, and so on.

So for any two days in the same year (March through December), there are a fixed number of days between them, which means a fixed number of whole weeks with a fixed number of additional days remaining after those weeks, which means a fixed offset in the week between them. As another example, April 1st always falls 31 days after March 1st, which is 4 weeks (28 days), with 3 left over. Therefore, April 1st always falls on a day of the week which is three days of the week later than the day of the week that March 1st fell on in that year: If March 1st is on a Friday, April 1st is on a Monday (Saturday is 1 day later than Friday, Sunday is 2 days later, Monday is 3 days later).

Everybody probably has an example or two of this concept that they use from time to time, a common one being that Christmas day and New Years Day always fall on the same day of the week (New Years Day, which you can think of as December 32nd, always falls 7 after Christmas day, the 25th). Now you know that you can (if you really want to) find relationships like this almost anywhere in the year (except January or February, unless you're careful about leap years). For instance, I know that my Wedding anniversary always falls 3 days of the week later than my birthday, which always falls 2 days of the week earlier than Halloween and one day of the week earlier than Christmas.

By the exact same token, there are certain dates of the year that always fall on the same day of the week as each other. Any pair of dates that are always 7 days apart fall on the same day of the week. In fact, any pair of dates that are always some whole-number-multiple of 7 days apart will land on the same day of the week: April 1st and April 8th (1 week), April 1st and April 15th (2 weeks), April 1st and April 22nd (3 weeks), April 1st and April 29th (4 weeks), and April 1st and April 36th, which is actually March 6th (5 weeks).

One of the main ideas behind using the doomsday rule is that if you remember what day of the week a paritcular date falls on for a given year, you can use this to find what day of the week nearby dates are. If I tell you that December 20th is on a Wednesday, then it's pretty is easy to find what day Christmas falls on: 5 days later goes Thurs, Fri, Sat, Sun, and Monday, so Christmas would fall on a Monday in that case.

Of course, if all I told you was that August 4th was on a Friday and asked you what day of the week Christmas was on, it'd be quite a bit harder to figure out. You could do it, but you'd have to count a lot further and keep track of which days have 30 days, and which have 31, and it would just generally be annoying. It's better if you have the days of the week for several dates spread out throughout the year, and then you can use the one closest to the date in question. Ideally, we'd also like to avoid crossing between months so we don't have to keep track of the extra 30 or 31 days. Therefore, we want to have one date for each month whose day of the week we know. Then we can use that to find the day of the week for any other day of that month by counting forward or backwards by 7's, until we're within 1 week, then figure how many more days we need.

So here you go, here are your key dates for this year (2009): Jan 1st is on a Thursday, February 8th is a Sunday, March 15th is Sunday, April 1st is Wednesday, May 15th is Friday, June 22nd is Monday, July 8th is Wednesday, August 2nd is Sunday, September 3rd is Thursday, October 10th is Saturday, November 1st is Sunday, and December 15th is Tuesday. There, now you just need to remember those twelve dates and the days they fall on, and you're all set.

What Conway discovered was that there is one particular set of dates that are easy to remember. First of all, all these dates fall on the same day of the week, so you just have to remember the dates, not the dates and the day of the week. Second, the dates themselves lend themselves to easy memory. For even numbered months (skipping February again), we remember the day of the month that has the same number as the month: April 4th (4/4), June 6th (6/6), August 8th, October 10th, and December 12th. All those dates happen to fall on the same day of the week as each other in any given year.

For odd months, (skipping January because of the leap year, and March for now), we put them in pairs and remember complimentary dates: July 11th (7/11) and November 7th (11/7), and May 9th (5/9) and September 5th (9/5). To remember which month to group, there's a simple mnemonic device: "I work from 9 to 5 at the 7/11". 9-to-5 is commonly cited as a typical working day, and 7/11 is a well known convenience store chain. These four dates also all fall on the same day of the week as each other, and on the same day of the week as the 5 dates we covered in the last paragraph (for the even numbered months).

The day of the week that these 9 dates fall on is called the "doomsday" for that year, for no other reason than the fact that John Conway apparently has a sense of whimsy. Remember, there's nothing inherently special about the doomsday; we could just as well have picked another set of dates that all fall on the same day of the week and called that the doomsday. The only reason we pick these particular dates is because it just happened to work out nicely that they're quite easy to remember. Also don't forget that these are not the only 9 days of the year that fall on the doomsday. Obviously, there are about 52 weeks in the year, so each day of the week is going to come up at least 52 times: it's not like October 10th is the only day of October that falls on the doomsday, we just remember these key dates because they're easy to remember.

January and February are a little tricky because the specific dates that falls on the doomsday change depending on whether it's a leap year or not. For non-leap years, January 3rd falls on the doomsday, and for leap-years it's January 4th. This is pretty easy to remember, too: For 3 years, doomsday is on January 3rd, in the 4th year, doomsday is on January 4th. (Remember that century years, even though they are multiples of 4, are not always leap years: most of the time they are non-leap years, so the doomsday is January 3rd. Only if the century year is also a multiple of 400 is it a leap year and has doomsday on January 4th).

For February, a doomsday is on the 28th for non-leap years, and on the 29th for leap years. This is easily remembered simply as the last day of February, regardless of the date.

The dates for March's doomsdays don't change from year to year, since it falls after the leap-day, but we saved it for last because it's mnemonic device is related to that of February: we already know that the last day of February (regardless of the exact date) always falls on the doomsday, but we can also remember this by the pseudodate of March 0th, which is the day before March 1st. This is a bit of a cop-out because now we only actually have 11 key dates instead of 12, if you want, you can always just remember March 7th, which is 1 week after March 0th, so it too falls on the doomsday.

So all together, we have the following dates which always fall on the same day of the week as eachother within a given year (the "doomsday" for that year):

  • January 4th in leap years, January 3rd on non-leap years.
  • Feb 29th for leap years, Feb 28th for non leap-years (the last day of February, always).
  • March 0th (the day before March 1st, which is the same as the previous one) or March 7th (0 + 1 week = 7)
  • April 4th, June 6th, August 8th, October 10th, December 12th (even months and their matching-numbered days).
  • May 9th and September 5th (9/5, a "standard" workday, and it's compliment 5/9).
  • July 11th and November 7th (7/11, the well known convenience store chain, and it's compliment 11/7).

Those in the US may also note that July 4th, Independence Day, falls on Doomsday (July 11th - 7 days = July 4th).

Finding the Doomsday

So now all you need to do is find out the doomsday for a given year, and you can pretty easily find what day of the week any date falls on for that year. But you still don't know how to find the doomsday for the year. Well, the biggest part of Conway's brilliance with this rule was finding a pretty simple formula to figure this out. There are two parts: the anchor day for the century, and the offset for the year.

Importantly, the Gregorian calendar repeats every 400 years. In other words, whatever day of the week January 19th falls on this year, it will be the same day of the week 400 years from now, guaranteed (unless the Earth's orbit moves or something). It's also the same day of the week it was 400 years ago, 800 years ago, and 40,000 years into the future. That's because 400 years is the longest period for any adjustments that are made to the calendar. These adjustments are the leap days which screw things up a little about every 4 years. If it was as simple as that, the calendar would cycle every 28 years, but it's not. There's actually an exception to the leap year that a lot of people don't know (because it hasn't come up in more than 100 years). Leap years only actually occur on years that are multiples of 4 that are not also multiples of 100 (i.e., century years), unless they are also multiples of 400. So in other words years that don't end in "00" are leap years exactly as we always thought; if they are multiples of 4. So 1904, 1908, 1912, 1916, etc., were all leap years. However, years that do end in "00" are century years (1800, 1900, 2000, etc) meaning they are multiples of 100. Three times out of 4, century years are not multiples of 400, so they are not leap-years: 1700, 1800, 1900 were all non-leap years. The most recent century year, 2000 happens to be a multiple of 44 (5*400 = 2000), so it was a leap year and nobody noticed anything weird.

The reason leap years were added in the first place was because someone realized the Earth takes a little longer than 365 days to orbit the sun, it takes closer to 365.25 days. by adding a leap day every 4 years, we get, on average, an extra quarter of a day per year as required. The reason for the century-year hassle is because the Earth's rotation is not exactly 365.25 days, either. It's actually about 365.242199. This extra .002199 is equal to about 1 over 454, so we now we need to loose 1 day about every 454 years. Well, their measurements we're probably quite as good back when this was first established, so they opted for loosing 3 days in 400 years. This puts the average number of days per year at 365.2425, which is off by 0.000301 days, which is actually a really good percent error (less than 1 ten thousandth of a percent). (Unfortunately, over long time periods, even such a small percent error can add up: after 4000 years, it will be off a bit more than a day. Some people are proposing even longer cycles for the leap year system).

This 400-year period of weirdness means that the calendar tries to repeat every 28 years, but it gets screwed up almost every time it has to cross a century. At best, the calendar could try to repeat every 400 years, but that's only if an exact whole number of weeks has passed in that time. If those 400 years cover 7 weeks and 1 day, then the calendar won't repeat for 2800 years. But it turns out, it is an exact number of weeks. 400 standard (non-leap) years would be 400*365 = 146000 days. For three of these centuries, there will be 24 leap years (because the century year itself won't be a leap-year), so we add another 3*24 days to get 146072 days. Finally, the remaining century will have a full 25 leap years, so we get another 25 days, totally 146097. Divide this by 7, and it turns out it goes in exactly: 20871 weeks.

Therefore, the days of the week and dates of the year will re-synchronize every 400 years, so if we can establish some pattern over a 400 year period, we can use it anywhere in the past or future (until they add more leap days).

That's exactly what Conway did, but fortunately, he did it in a smart way that makes it a lot easier. Instead of coming up with a formula to cover the 400 year period, he came up with a formula to cover a 100 year period, and then used offsets to adjust per century. Think about it a little, and you'll see this is perfectly legitimate. Once we get past February of the first year of the century (which, for our cases, is the '00 year, not the '01), there is a fixed number of days between any two dates in the entire century. For instance, there are 365 days between March 1st in '00 (of any century) and March 1st of '01 in the same century. Likewise, there are 730 days (2 common years) between March 1st '00 and March 1st '02, and 1095 days between March 1st of '00 and March 1st of '03. The '04 of every century is a leap year (it's a multiple of 4, but not of 100 so it's not subject to the 400 year weirdness), so to get to March 1st of '04 requires an extra day (February 29th): there are always 1461 (3*365 + 366) days between March 1st '00 and March 1st '04 for any given century.

From the last example you can see that, once you get past February of the century year, and until you get to the next century year, the leap years obey the easy 4-year rule, and there are no surprises: the number of days between any two dates is the same for every century. It therefore is perfectly reasonable that we can devise a set of relative rules to cover just the century long period, and then offset it as needed depending on which of the four centuries we're in.

Before we get to the rules for within the century, let's see about those offsets. In most centuries (3 out of 4), there are only 24 leap-years, because the century year will not be divisible by 400 and will therefore not be a leap year. Therefore, the entire 100 year span will have 36500 common days (365 per year times 100 years), plus 24 leap days, giving us 36524 days in the century. If we divide this by 7 days per week, we get 5217 full weeks, with 5 days left over. In other words, if he start on January 1st of '00, and go forward exactly 5217 weeks, we'll be on the same day of the week, but 5 days short of the next century (December 26th, '99). If we go forward one more week, we'll still be on the same day as Jan 1st '00 of the last century, but we'll be 3 days into the new century (Jan 3rd, '00 of the next century, if you think it should be Jan 2nd, count out 7 days after Dec 26th). To get back to Jan 1st, '00 of this new century, we need to roll back two days, which means we're two days of the week earlier than we were 1 century ago.

So that's the rule 3 times out of 4: In a century that has only 24 leap years, January 1st, '00 of that century is two weekdays ahead of January 1st, '00 of the next century (not that it doesn't matter if that next century has 24 or 25 leap years, since Jan 1st comes before the leap day).

The fourth time, the century has an extra day, which means it's going to eat up one of those 2 days. When a century has all 25 leap years, Jan 1st, '00 of that century is just 1 weekday ahead of Jan 1st, '00 of the next century.

If you dig up some old calendars, you'll find that Jan 1st, 2000 was on a Saturday. The three centuries preceding that all had just 24 leap years, so we have the bump the week day up by two days each century we go back: Jan 1st 1900 was on a Monday, Jan 1st 1800 was on a Wednesday, and Jan 1st 1700 was on a Friday. The century starting with the year 1600 had 25 leap years, so it's only 1 day ahead of 1700: Jan 1st 1600 was on a Saturday.

So now if you know what day of the week January 1st of the '00 fell on in a given century, you can find it for the remaining centuries. But since we already have a set of dates that we're trying to remember (the 11 or 12 doomsday dates given above), we'll adjust it to fit these. In the year 1800, January 1st was on a Wednesday (as we went over above). It was a non-leap year, so the key doomsday date for January is Jan 3rd, which was two days later, on a Friday. This was the doomsday for the year 1800.

Likewise, Jan 1st, 1900 was a Monday, so doomsday for that year (Jan 3rd) was Wednesday. For the year 2000, January 1st was a Saturday, but it was a leap year so doomsday was Jan 4th, which was Tuesday. Since the century starting with 2000 has 25 leap years, Jan 1st of 2100 will only be one day behind Jan 1st of 2000, so that will be a Friday. Doomsday will be back on Jan 3rd, a Sunday.

Conway calls the first doomsday of each century (the doomsday for the '00 year) the anchor day for that century (starting in '00 and going all the way through '99). All you need to remember is 4 of these, which covers the 400 year period of the calendar, and you can find the anchor day for any other century. The anchor days are usually presented as follows:

Century Anchor day Offset Mnemonic device
1800 - 1899 Friday 5 "Five-day"
1900 - 1999 Wednesday 3 "We-in-dis-day", which worked better back in the 1900's.
2000 - 2099 Tuesday 2 "Two's-day", recalls the "Tues" and the 2nd millenium
2100 - 2199 Sunday 0 "Twenty-One day is Sunday" (it rhymes, and 21 is the century number)

To find the dooms days for the rest of the years in the century, you use the following formula:

Doomsday for century-relative year y = (floor(y/12) + y % 12 + floor((y%12) / 4)) % 7 + Anchor

The century-relative year y is the last two digits of the year, which is actually just the full year taken modulo 100. For 2009, y is 9, for 2374, y is 74, etc.

The first term is floor(y/12), which means divide y by 12, and take only the whole number part of the result (or, identically, round the quotient down to the nearest integer). The y value can be as high as 99, so this value can be as high as 8 (8*12 is 96 < 99, but 9*12 = 108 > 99).

The second term is y modulus 12. This simply means the remainder that's left over after doing the division in the first term. For instance, if y is 79, 12 goes into it whole 6 times: 12 * 6 is only 72, so there are 7 left over, this is the remainder and the value of the second term.

The third term takes this same remainder, and divides it by 4, then takes the floor again (rounds down to the nearest integer).

All three terms are added together, and taken modulo 7. Again, this just means divide by 7, and see what the remainder is. This gives one of seven values, 0 through 6, which nicely corresponds to the days of the week. Finally, we offset the anchor day (forward) by this much to get the doomsday for this year.

As an example, we'll do 2009. The century is 2000, so the anchor day is "two's-day": Tuesday. The century-relative year, y, is 9. Dividing by 12 gives 0 (the first term) with 9 left over (the second term). Take this remainder (9), and divide by 4. Four goes into 9 two whole times, and leaves some left over that we don't care about. The third term is 2. Adding these all together gives 0 + 9 + 2 = 11. Seven goes into 11 once, and leaves 4 left over, so this is the value modulo 7. Now we offset the anchor day, Tuesday, by 4: Wednesday (+1), Thursday (+2), Friday (+3) and Saturday (+4). Therefore, doomsday for 2009 is Saturday.

Let's do a harder one: 2383. Well, the closest century we remembered the anchor for was 2100, which has an anchor on Sunday. That's the end of our list, so we just loop back around to the top: 2200 has the same anchor day as 1800 (they're 400 years apart and remember, the calendar recycles every 400 years), which is Friday, and 2300 has the same anchor day as 1900, which was Wednesday ("We-in-dis-day" if you were born in the 1900's).

The century-relative year is 83. Twelve goes into 83 six full times, 12*6 = 72, leaving 11 left over (83-72=11). The first two terms are 6 and 11, respectively. The third term is floor(11/4): 4 goes into 11 twice, but not three times, so the third term is 2. Adding them all up gives 6 + 11 + 2 = 19. Seven goes into this twice, to give 14, leaving 5 left over, so that's our remainder term. Offset the anchor day, Wednesday, by 5 to get Thur, Fri, Sat, Sunday, and Monday: The doomsday for 2183 will be Monday.

Just for a little extra practice, what day of the week will April 21st fall on in that year (2183)? We know April 4th (4/4) falls on doomsday, so count up by sevens from there: 4, 11, 18, 25. The 21st is three days forward from the 18th, and four days backwards from the 25th. You can do it either way: the 18th is on doomsday, Monday, so three days later will be Tues, Wed, Thursday. The 25th is also a Monday, so four days backwards from there will be Sunday, Saturday, Friday, Thursday. Both ways work fine, and April 21st, 2183 will be on a Thursday.

Deriving the formula

So where does this formula come from and why does it work? Let's see if we can figure it out. In a common year there are 365 days. That's 52 weeks with 1 day left over (52 weeks times 7 days per week is 364 days). By the same logic we discussed above when we were figuring out the anchor days, January 1st in a common year will be one day of the week before January 1st of the next year. If they are both common years, then January 3rd will be doomsday for both of them, which means doomsday of the second year will be one day of the week later than doomsday of the previous year. This is only if they're both common years. How often does that happen? Well, if we ignore the '00 for now, then '01 to '02 works and '02 to '03 works. '04 is always a leap year so it doesn't for '03 to '04 or '04 to '05. But it starts working again for '05 to '06, and '06 to '07. '08 is another leap year, so it doesn't work there, either.

So let's see about the transition from a leap year to the next year (we're still ignoring '00 for now). The leap year has 366 days, which is 52 weeks with 2 days left over. If we go forward exactly 52 weeks from January 1st of the leap year, we get to December 30th of the same year (2 days short of the next year), and it's on the same day of the week. That means January first of the next year is 2 days later, which is 2 days of the week past January 1st of the leap year. Now we have to get from Jan 1st of each year to the doomsday of that year. Let's say Jan 1st of the leap year is on day X. Doomsday for that year is Jan 4th, which is on day X+3. We just established that Jan 1st of the next year is on day X+2. Doomsday for this year is on Jan 3rd, which is two days later, which would be X+4. So doomsday for the leap years is X+3, doomsday for the following year is X+4, only one day later again.

Great, so leap year to the next year moves the doomsday forward one day, and each of the next two transitions also moves it forward by one day of the week. So if doomsday is on day D in '04 for instance, it will be on D+1 in '05, D+2 in '06 and D+3 in '07. Now let's see about '07 to '08 (moving into a leap year).

If the year before a leap year has January 1st on day of the week X (a different X now), it's 365 days till January 1st of the leap year. We already established that's 52 full weeks plus one day, so January 1st in the leap year will be on day X+1. The doomsday for the non-leap year is Jan 3rd, which is day X+2. In the leap year, doomsday isn't until Jan 4th, which is 3 days after Jan 1st. Jan 1st is X+1, so doomsday in the leap year is X+1+3 = X+4. This is 2 days later than X+2, the doomsday for the previous year. Therefore, transitioning from a non-leap year into a leap year bumps the doomsday up by 2 days instead of just one.

So far, we've seen that moving from a non-leap year to a non-leap year, or from a leap year to a non-leap year, causes the doomsday to move forward 1 day of the week, and that transitioning into a leap year (which will alwyas be from a non-leap year, two leap years can never be back to back) moves the doomsday up by 2 days of the week. But, we haven't even looked at the 400 years strangeness in '00, we don't know if that's going to affect us. So let's take a look.

We'll start with the common case: 3 out of 4 times, '00 will not be a leap year. If it's a non leap year, than it has 365 days which is 52 weeks and one day, so if Jan 1st of '00 is on day X, then Jan 1st of '01 is on day X+1. Doomsday is on Jan 3rd in both years (non leap-years) which is X+2 in '00 and X+3 in '01, so doomsday is one day later in '01 than in '00, just like we found before. And it better be, because we already established that doomsday advances by 1 day when transitioning from a non-leap year to a non-leap year. The same happens going into '02 (X+4), and '03 (X+5). We should already know what happens to doomsday when going into a leap year, but just to make sure: Jan 3rd of '03 is doomsday, which is X+5 that year. Jan 1st is two days earlier, on X+3. January 1st of '04 is 365 days later, which is 52 weeks and one day, putting Jan 1st '04 on X+4. Since '04 is a leap year, doomsday is on Jan 4th, which is three days later on X+7; it moved up by 2 from the previous year's doomsday, X+5. That's just what we thought.

But remember, day X was for Jan 1st of '00. Doomsday of that year was 2 days later on X+2, so doomsday in '04 (X+7) is 5 days later than doomsday of '00. Remember, we had a special name for doomsday in '00; we called it the anchor day. We'll call this day of the week A, so doomsday in '04 is on day A+5. The sequence of doom's days in the first 5 years from '00 to '04 is A, A+1, A+2, A+3, A+5.

Now let's look at the other 25% of the time, when the '00 year is a leap year. Does this change anything? Well, if Jan 1st of '00 is on day X, then Jan 1st of '01 is two days of the week later this time, on X+2. The doomsday of '00, which is the anchor day, A, is on Jan 4th, so A = X+3. Doomsday of '01 is Jan 3rd, which is X+2+2 = X+4 = A+1. So once again, we have the doomsday advancing just one day from '00 to '01. It looks like nothing changed: from '01 to '02 it will go to A+2, '02 to '03 if will go to A+3, and '03 to '04 it will go up by two as always to A+5, same as before.

So there we have it, even starting with '00, for any century, doomsday for non-leap years is one day of the week past where it was in the previous year, and doomsday for leap-years is two days later than in the previous. Since we are starting with '00, and ending with '99, we don't need to worry about transitioning into '00, so we don't need to consider that strangeness: as long we're staying in the same century, the doomsday works like a counter that starts at the anchor day for the year and steps forward by one day every year, plus one extra step every four years, always wrapping from Saturday to Sunday / Sunday to Monday (depending on when your weeks starts).

Setting up this counter is easy: we've already got something that advances by one every year: the year. It even starts at 0 at the beginning of the century, so we're all set there. Now we just need to add on something that advances by one every four years. Easy, we just need something that advances at one quarter of the speed of the year, so let's just divide the year by 4. the only problem here is that we don't want a "smooth motion" for this part, ticking away at 1/4 of a day per year. We just want it to sit still for 3 years, then bump up by 1 on the fourth year, and repeat that forever. That's also easy, we just use the floor function which means "round down to an integer".

So our formula looks like this: A + y + floor(y/4).

It doesn't look much like Conway's formula, except for the divide by 4 and floor-it. Let's test a few examples, see if they work out the same. We'll start with 2009. A is Tuesday for the 2000's century. By our formula we get doomsday is Tuesday + 9 + floor(9/4) = Tuesday + 9 + 2 = Tuesday + 11 = Tuesday + 4 = Saturday. Conway's gives Tuesday + floor(9/12) + (9%12) + floor((9%12)/4) = Tuesday + 0 + 9 + floor(9/4) = Tueday + 9 + 2 = Saturday, same as ours.

Let's go for year '92. It's doesn't matter what century it is, because we haven't changed the anchor days at all, just the way to calculate the offset from the anchor day. By our formula, we have 92 + floor(92/4) = 92 + 23 = 115 which is the same as 3 under modulus 7. Conway's gives floor(92/12) + (92%12) + floor((92%12)/4) = 7 + 8 + floor(8/4) = 7 + 8 + 2 = 17, which is 3 under modulus 7. So it's the same.

It turns out that both formulas work perfectly well, giving the same values for any value of y. We'll see in the next section that Conway's formula is actually the same thing as ours: a counter that starts at 0, increments by 1 day every year, and skips up an extra day every 4 years. The reason for the extra bit of stuff in Conway's formula (compared to somewhat "leaner" looking formula we came up with) is to make the mental arithmetic a bit easier. Take the last example: in our formula, we had to mentally divide 92 by 4, and take the rather large value of 115 under modulus 7. In Conway's formula, the large values are disposed of with a divide by 12, which is not too difficult to do in your head since the biggest quotient you can get is 8, and most people knew the times tables through 12 at least at some point in their lives. The second term comes out of the same operation as the first term, you just need to subtract two numbers that are with 12 of each other and both less than 100. The final term is a divide by 4 of a value that is no more than 11, so that's easy, too. Finally, you have to take the sum of all of these values and evaluate under modulo 7. The biggest conceivable value you imagine getting from summing these three terms is 8 + 11 + 2 = 21, and in fact it turns out you never actually do get a value greater than 20 (because when the first time is 8, the second term can't get past 3 with a year less than 100, so you're maxed out when the first term is 7 and the second and third term as 11 and 2, respectively). Taking a value less than 21 under modulus 7 is pretty easy to do in your head, or just counting out on your fingers.

Moral of the story, Conway most likely came up with the same formula we did, and then figured out a clever way to make it more manageable so he could wow his friend's and colleagues by doing the calculations in his head.

So where did that 400 year weirdness go?

We already accounted for it when we figure out the anchor days, remember? Leap years only effect the doomsday when transitioning into them, which, in the case of centurial leap years would mean going from a '99 of one century to '00 of the next. This transition isn't covered by the formula we just derived, or by Conway's; they only work within a century, not between them. If it wasn't for the 400 year weirdness, than yes, we could use either of these formulas to figure out the offset of the doomsday for any year in the 400 years span relative to the super-Anchor: the doomsday of the first year in the 4 centuries. Then we would only have to remember one anchor day, instead of 4, but we'd also have to work with larger y values and offset them from the beginning of the 4-century period, instead of just getting off all but the bottom to digits (mod 400 instead of mod 100). And anyway, we can't do it because we do need to obey the 400 year weirdness.

Ignoring the formulas for a moment, the transition from '99 to '00 would usually (3 times out of 4) bump the doomsday up one day of the week. That's relative to '99; what is it relative to '00 of the previous century? Well doomsday for '99 is offset 99 + floor(99/4) = 99 + 24 = 123, which is 4 under modulus 7 (did this according to our formula, obvious Conway's gives the same: 8 + 3 + 0 = 11 which is 4 under mod 7). So that would mean '00 of the next century is offset one more, so it would be offset 5 from '00 of the previous century. Under mod 7, +5 is the same as -2, so the doomsday for '00 of one century is 2 days of the week earlier than doomsday of '00 of the previous century. That's exactly what we have for the anchor days when the second century only has 24 leap years.

For the other 25% of the time, the transition from '99 to '00 of the next century, when that '00 is a leap year, bumps up doomsday by 2 days, as we've seen. '99 is still 4 offset from the anchor day for it's century, which makes anchor day for the next century (doomsday of '00) offset 6, which is the same as -1. So anchor day for a century that has 25 leap years is one day of the week earlier than the previous century. Again, that's exactly what we found before.

So basically, the anchor days abstract this information into a tight little package of just 5 things to remember (the 4 anchor days, and the century they start on. Okay, technically it's 26 things to remember, because you need to remember the four anchor days, which of the 24 possible orders they go in, and which century they start at.) The alternative is to use bigger numbers (years mod 400) in a (slightly) more complex formula, such as:

y + floor(y/4) - floor(y/100)

Here, y is the year modulo 400. The first term bumps doomsday forward one day every year, the second term bumps it an extra day every 4 years, but the third term undoes this every 100 years (non-leap centurial years). This gives the offset from the super-anchor, which would be Tuesday, corresponding to the anchor day for centuries with 25 leap years (1600's, 2000's, etc). A fourth term to add the leap day every 400 years isn't needed, because the formula resets after y = 399. The last year in the 4-century span (e.g., 1999) is correctly given a doomsday of Sunday by this formula. Going forward into the next year would be moving into a leap year, and would bump doomsday 2 days forward to Tuesday, which is the Super-anchor: the formula just reset.

Conway's formula

Let's just look at the different terms inside Conway's formula. We'll ignore the + A for now and just focus on finding an offset number of days from the Anchor day. We can also basically ignore the %7 operation, this just adjusts our number to the context of days of the week. Since there are seven days of the week, the result of our value wraps around every 7 values: if 0 gives us Sunday, then 7 days later will also be Sunday.

So we can focus on the three terms inside the modulus operation. Dividing the year by 12, and taking the floor is going to contribute a certain number of days, from 0 to 8 (inclusive). Specifically, the number of days that are contributed by this term will go up by one every 12 years.

The next term is the remainder of the year divided by 12. This values goes up by one every year for 12 years, then resets to 0 after reaching 11. In otherwords, it tries to push the doomsday up by one year every year for 12 years. On the 13th year, it tries to drag the it back by 11 days (from the previous year). However at the same time, the first term is finally trying to bump it up by one more year, so the net result (from just these two terms) is to drag it backwards by 10 days relative to the year before it. However, this is the same as going backwards 3 days, because there are 7 days in the week. Alternatively, it's the same as going forward 4 days. So let's see what happens with just these two terms in the first 13 years of the century (from '00 to '12, inclusive). From just these two terms, we would get A+0, A+1, A+2, A+3, A+4, A+5, A+6, A+7=A+0, A+8=A+1, A+9=A+2, A+10=A+3, A+11=A+4, A+0+1=A+1, etc.

Now we'll consider the third term. This is being fed with a value which, as we just discussed, increments each year from 0 to 11, then falls back to 0 and starts again. Dividing by 4 and taking the floor produces a counter that increments ever 4 years, just like dividing by 12 gave a counter that increments every 12 years. So in these same 13 years, this final term is contributing 0,0,0,0,1,1,1,1,2,2,2,2,0, and it starts over in that last step along with the previous term.

taken all together, we have the second term generally driving the doomsday forward one day each year. In '04 (or the fifth year in general), the third term is going to bump up as well, so the doomsday will advance by two days. This corresponds to entering a leap year, as we already saw. All this time, the first term is staying constant and therefore not impacting the doomsday at all.

The first and third terms stay constant again for the next three years, leaving the second term to drive doomsday forward one day per year. Then the second leap year roles around, the third term bumps again, and doomsday goes forward another two days. The first and third term stay quiet again and let the second term finish up the 12-year span by bumping doomsday forward one day per year.

Going into the 13th year (e.g., '12), the first term finally bumps, but the second and third terms reset to 0. We loose 11 days from the second term, and 2 from the third, making 13 all together. The bump from the first term reduces this to only a 12 day loss. Taken modulus 7 (in other words, wrapping as appropriate for a day-of-the-week calculation), this is the same as loosing 5 days, or, the same as gaining 2 days. Since this year is a multiple of 12, it's also a multiple of 4, so it's a leap year: we gained 2 years just like we were supposed to. In the next year, the first and third terms will remain constant and the second term will start bumping again, one day per year.

So now we see what Conway's formula really is: a counter that starts at 0 and increments by 1 most of the time, but skips up an extra step every 4 years, like as we established in the last section.

How to get better at finding the day of the week

Practice. Specifically, practice counting up and down by 7's. You don't have to count past 31, but you do need to be able to start from anyone of the key dates. So for instance, starting from the 9th (or some month, probably May), count up by sevens to get 9, 16, 23, 30. Counting down from 9 is 9, then 2. Just practice this, that's all, starting from all the different dates. Once you get to within a week, counting out days on your fingers is helpful, just remember to go the right way. For instance, to find what day of the week Oct 20th falls on in 2009, I start with October 10th, the doomsday, which is Saturday for 2009. Counting by 7's gets 10, 17, 24. The 20th is four days before the 24th, so I put up four fingers, and trace the week backwards before Saturday (the doomsday). So I start on Friday with the first finger, reach the second finger with Thursday, the fourth finger with Wednesday, and the final finger, the 20th, on Tuesday. Altneratively, I could have counted up 10, 17 and stopped, then counted three days forward to get to the 20th: Sunday, Monday, Tuesday.

Finding the doomsday for a particular year is a little more tricky, but with practice it can get pretty easy. Most of the time that you need to know what day of the week a date falls on, it will be in the current year, in the next year, or maybe in the previous year. To speed yourself up in these common cases, you can just remember the doomsdays for this year, next year, and last year, and then skip that part of the calculation.