# How to find the probability of extra Sundays in a leap year?

What is the chance that a leap year will have 53 Sundays?

As per my trial, will it be 2/7? Since 366 days in a leap year means 52 weeks and 2 more days, so from the extra two days, the probability of Sunday is 2/7.

P.S : This was a question I found in a basic statistics book.

The Gregorian calendar favors five of the seven weekdays during leap years. Therefore the chance is not precisely $2/7$.

This was essentially problem B3 in the 1950 Putnam Mathematics Competition:

$n$ is chosen at random from the natural numbers. Show that the probability that December 25 in year $n$ is a Wednesday is not 1/7.

In the Gregorian Calendar, years that are multiples of $4$ are leap years (with $7\times 52 + 2=366$ days), but years that are multiples of $100$ are not leap years (and therefore have $7\times 52+1=365$ days), with the exception that years that are multiples of $400$ are leap years. (Many of us remember the most recent exception in $2000$.) This creates a $400$ year cycle containing $400/4 - 400/100 + 400/400 = 97$ leap years.

What is especially interesting is that the total number of days in this cycle is a whole multiple of seven:

This shows that the $400$ year cycle comprises a whole number of weeks. Consequently, the pattern of days of the week is exactly the same from one cycle to the next.

We may therefore interpret the question as asking for the chance of $53$ Sundays when sampling randomly and uniformly from any $400$-year cycle of leap years. A brute-force calculation (using, say, the fact that January 1, 2001, was a Monday) shows that $28$ of the $97$ leap years in each cycle have $53$ Sundays. Therefore the chance is

Note that this does not equal $28/98 = 2/7$: it is slightly greater.
Incidentally, there is the same chance of $53$ Wednesdays, Fridays, Saturdays, or Mondays and only a $27/97$ chance of $53$ Tuesdays or Thursdays.

For those who would like to make more detailed calculations (and might mistrust any mathematical simplifications), here is brute-force code that computes and examines ever day of the week for a given set of years. At the end it displays the number of years with $53$ appearances of each day of the week. It is written in R.

Here is its output for the $2001-2400$ cycle:

Friday    Monday  Saturday    Sunday  Thursday   Tuesday Wednesday
28        28        28        28        27        27        28


Here is the code itself.

leapyear <- function(y) {
(y %% 4 == 0 & !(y%% 100 == 0)) | (y %% 400 == 0)
}
leapyears <- seq(2001, length.out=400)
leapyears <- leapyears[leapyear(leapyears)]
results <- sapply(leapyears, function(y) {
table(weekdays(seq.Date(as.Date(paste0(y, "-01-01")), by="1 day", length.out=366)))
})
rowSums(results==53)