Working out the day of the week Working out the day of the week by Steven Flintham (15A) Introduction It's possible some of you used to watch "Jim'll Fix It" back in the mid-80s; if you didn't, this introduction won't be much use, but try to stay with me. ;-) One of the few things I can remember from it was a fairly old (at least by the standards of the usual 'guests') man who wanted to take part in a fake 'Mastermind' game working out the day of the week. He was given dates like '09/03/1982' and he'd say 'Tuesday' almost immediately - and he was always right, if I remember correctly. They had a little computer display in the corner of the screen (which, for what it's worth, looked very much like it was part of a BBC mode 7 screen), showing the correct answers for our benefit. I was quite impressed by this at the time, and thought he must have some sort of gift. (Albeit a not incredibly useful one. ;-) ) Maybe he did, and I suspect he must have had at least a reasonable ability at mental arithmetic and/or a good memory. But it turns out that there's an easy way of doing it, whether or not he was doing it like that himself, and I was really impressed with it when I found out about it. (There are probably several other roughly similar methods.) "What's this got to do with the BBC?", you ask. Well, this article explains how to do it, and there's an accompanying program to do worked examples for you if you need them, and to help you test yourself. References I found out about this method from the sci.astro FAQ, revision 2.10, part 3. I've sent a copy of it to CJR along with this article so you can read it for yourself if you wish. The FAQ says that the method was originally from volume two of a book written by John Horton Conway with Guy and Berlekamp called 'Winning Ways'. The basic idea You might find it helpful to have a calendar and/or diary to hand while following this, although it's by no means necessary. The first thing to note is that, although the question 'What day of the week was June 7th 1996?' is hard to answer (unless you know a method to do it), the question 'What day of the week was June 7th, given that June 19th was a Wednesday?' is much easier. All you have to do is count through the days - the 19th was a Wednesday, so the 18th was a Tuesday, and so on. Admittedly this is slow, but you can do a sort of 'date arithmetic' for dates within the same month; you'll probably be able to work something out for yourself, but if you can't or don't want to, I'll outline some ways of doing it later. So, in order to answer questions like 'What day of the week was June 7th 1996?', what you really need is a way of finding out what day of the week some day in June 1996 was. The key idea is that, in any non-leap year, the following dates all fall on the same day of the week (called the 'Doomsday'): January 3rd, February 0th, March 0th, April 4th, May 9th, June 6th, July 11th, August 8th, September 5th, October 10th, November 7th and December 12th. Yes, I know there's no such date as 'February 0th' - but it's a convenient shorthand for 'the last day of the January'. Why not just say 'January 31st'? Well, without this there isn't a day in February and March which you know falls on a particular day of the week, which would be a bit awkward. Perhaps more importantly, it helps to simplify handling leap years, because the last day of February is always March 0th, whereas it can be either February 28th or February 29th in conventional terms. You need to remember those dates, but it's not as hard as it looks. You do have to remember January 3rd, February 0th and March 0th separately, but look at the rest of the list written out in numerical form as day/month: 4/4, 9/5, 6/6, 11/7, 8/8, 5/9, 10/10, 7/11 and 12/12. All the even-numbered months are simple, which just leaves 9/5, 5/9, 11/7 and 7/11. They come in pairs, so you really only need to remember 9/5 and 7/11. And there's a simple mnemonic for remembering these: "I went to my 9-to-5 job at the 7-11." (According to the sci.astro FAQ, '"Seven-Eleven" is the name of a ubiquitous chain of convenience stores.') How do you know what the Doomsday is for the year you're interested in? There's a way of working it out, which I'll describe below, but if you only want to do the calculation for one or two years (such as the current year), it's probably easiest to look it up on a calendar and just memorise it. (This is what I do at the moment.) To save you looking it up for yourself, the Doomsday for 1998 is Saturday. The final complication, if you already know the Doomsday for the year, is that in leap years the January 3rd and February 0th don't fall on the Doomsday; you need to use January 4th and February 1st instead. Date arithmetic So, now you have one date in every month which you know falls on the Doomsday, and you know what the Doomsday is. Suppose you want to know what day of the week June 20th 1998 is. You know, from the above, that June 6th 1998 is a Saturday. 20-6=14=2*7, and since the days of the week repeat on a seven day cycle, June 20th is also a Saturday. What about December 23rd 1998? You know that December 12th 1998 is a Saturday. 23-12=11=7+4. You can ignore the 7, because that takes you from a Saturday back to a Saturday, so the 23rd is the day of the week four days after a Saturday. Which day of the week this is might be obvious to you, but I prefer to number the days (Sunday = 0, Monday = 1, ...) and say Saturday + 4 is 6+4=10=7+3, and discarding the 7 gives 3, which is Wednesday. (In case it's not obvious, you can start the numbering on any day you want, so if Wednesday = 0 seems more natural to you then go ahead. You can also number starting from 1 if you want.) By 'ignoring 7s', what you're really doing (of course) is taking the remainder on dividing by 7. So, in the previous example, you can also think of it as 23-12=11 and 11 remainder 7 is 4, then carry on as before. Both of those examples 'coincidentally' had the date in question after the 'special' day. What about September 3rd 1998? You know September 5th is a Saturday. Because the special day is always near the start of the month, you can just count the days backwards from the special day if you wish. Alternatively, because of the seven day cycle, September 10th falls on the same day of the week as September 3rd, so you can just work with September 10th. 10-5=5, so September 10th (and hence September 3rd) falls on Saturday + 5, i.e. a Thursday. Finally, an example using a special day which is a '0th', just to show it makes no difference. What day of the week is March 9th 1998? March 0th is a Saturday, from above. 9-0=9=7+2, so March 9th is Saturday + 2 = Monday. This might look a bit complicated, but it isn't really. The clever bit is the way you have a special day in each month which falls on a known day of the week (the Doomsday). Using that to work out what day of the week another day in the same month falls on isn't difficult, but if you want to do it quickly in your head you'll probably need to spend a little bit of time working out your own system for doing it. The above is roughly how I do it myself, so it suits me quite well, but other people might prefer different methods. Arithmetic modulo 7 For anyone who's interested, I'll describe briefly exactly how I do the calculation. I use arithmetic modulo 7 - that is, arithmetic where you only 'really' have the numbers 0-6. All the other numbers are just alternative names for one of these numbers - in fact, the number which they differ from by a multiple of 7. So 20 is another name for (the technical phrase is 'congruent to') 6, because 20-2*7=6, and 983 is another name for 3, because 983-140*7=3. Negative numbers are allowed as well; -19 is another name for 2 because -19+3*7=2. Because of this, it's correct (more-or-less) to write things like 20=6, 983=3 and -19=2. In effect, you can add or subtract 7, or any multiple of it, at any point. That's just the background, but working modulo 7 the calculations become even simpler. What day of the week is December 23rd 1998? December 12th 1998 is a Saturday (day 6). So the 23rd is 23-12+6=11+6=17=3, i.e. a Wednesday. The nice thing (as far as I'm concerned) is that there's no longer anything at all special about days which fall before the special day. What day of the week is December 3rd 1998? December 12th is a Saturday (day 6). So the 3rd is 3-12+6=-3=4, i.e. a Thursday. In date calculations like these, working modulo 7 is really just a version of the 'use September 10th instead of September 3rd, because they're the same day' trick mentioned above. I just find it a nice easy way to think about it, because the 'adding 7s' is done in the arithmetic rather than as an extra 'ah, September 3rd is before the special day, so I need to add 7'-type step beforehand. I just say to myself '3-5+6' and then it's all simply arithmetic modulo 7. Working out the Doomsday If you've got real ambition, or if you want to work with a year for which it's not convenient to check on a calendar, the last thing to master is working out the Doomsday for a given year. I can't do this in my head yet, but sooner or later I intend to try and master it. For any 19xx year, work out xx/12, giving a quotient Q and remainder R. Then divide R by 4, giving a quotient Q2. (You don't need the remainder for this second division). The Doomsday is then Wednesday + Q + R + Q2. So, for 1998: 98/12=8 remainder 2, i.e. Q=8, R=2. R divided by 4 is 0 remainder 2, so Q2=0. Wednesday + Q + R + Q2 = Wednesday + 8 + 2 = Wednesday + 10 = Saturday, as I said above. The last complication is that Wednesday has be replaced by Tuesday for 16xx and 20xx years, Sunday for 17xx and 21xx years and Friday for 18xx and 22xx years. Wednesday works for 15xx and 23xx years. The cycle repeats over a four century period, so (for example) use Tuesday for 24xx dates. The program The program is fairly simple and should be easy to use. It will work through the calculations for any date in the years 1900-2099 inclusive, and also give you a ten question test on years of your choice within this range. Any comments on either the program or this article are welcome.