# Perpetual calendar

#### The initial question

Did you ever ask yourself which day of the week will the Xth day of month Y fall on?

There’s a simple and exact method that gives you the weekday of a particular date.

Let’s see it through a practical example. Memorise by heart the following 12-digit number, each digit corresponds to a month of the year **2012**.

J F M A M J J A S O N D 6 2 3 6 0 4 6 2 5 0 3 5

From there, **add up** the offset given by the table above for the month sought to the day sought, this comes down to the value S.

##### Example: let be the 21st of June 2012 the day of the week to search for.

The chart returns 4 for June, hence 21+4=25=S

Then, seek the remainder **r** of the division of S by **7**

S=25, hence r=4, indeed S=25=4+(a multiple of 7)=4+21.

*Hint: to quickly get the remainder r, you only need to substract the greatest multiple of 7 less than S from S, this multiple is inevitably in the following list: {0,7,14,21,28}.*

The remainder r leads to the weekday! 0 for Sunday, 1 for Monday . . . , and 6 for Saturday.

In the example above, r=4 <=> Thursday, hence the 21st of June 2012 falls on a *Thursday*.

##### Another example: the 25th of December 2012

December <=> 5, hence S=30, r=2,(30=2+28), the 25th of December 2012 is a *Tuesday*.

Still skeptical? Or seeking tests ? Click here to display the calendar for 2012.

#### So what’s the trick?

You already know that weekdays work in a 7-cycle fashion. The only unobvious point is what weekdays starts each month. When you know this information, there’s no more unknown, you have all the pieces to answer your initial question.

To find the 12-digit offset figure yourself, use the calendar function of your phone or a computer. All you have to do is write down the rank of the 7th day of each month, observing the following mapping:

0=Sunday, 1=Monday, 2=Tuesday, and so forth up to 6=Saturday.

Once you know this number you just have to apply the method seen above.