0
$\begingroup$

I was recently given the following problem on a test:

Find the dates on which Sunday fell in July, $1776$.

First, I noted the date on the day of test — $15$ October $2023$ to be a Sunday. Thereafter, I used the observation that the days were periodic with period $7$, meaning that after every seven dates, the same day is observed.

Using this, I found out that on $1$ October $2023$ was a Sunday, then used this for the previous few months to find that $2$ July $2023$ was a Sunday. Then I counted that there lied $59$ leap years and $187$ regular solar years between $1776$ and $2023$. Before and inclduing $2$ July $2023$ were $183$ days of the year $2023$. After the month of July were $153$ days in $1776$. Suppose that on $x$ July, $1776$ a Sunday was seen, thus yielding the equation:

$$59 + 365\cdot 246 + 183 + 153 + (31-x)\equiv 0 \pmod 7$$ $$x \equiv 0 \pmod 7$$ which should mean that the $7, \ 14, \ 21, \ 28$th of July $1776$ were Sundays.

However, I wonder if there exists a simple closed form expression that can be used to calculate the same. Is there some other alternative way to find this? I'm pretty sure that such calculations have been extensively studied and there exists one.

Help and insights are appreciated.

$\endgroup$
1
  • 1
    $\begingroup$ There are various algorithms, but none of them are particularly simple because of the varying lengths of months, years and centuries. $\endgroup$
    – ConMan
    Commented Oct 16, 2023 at 10:48

1 Answer 1

2
$\begingroup$

Write a function that calculates the days from Jan 1st 1600 to a given date. Add n-1 for the n-th day of the month. Add days depending on the month assuming February has 28 days, that is easiest done with a little table. Add 365 for every year after 1600.

Then add leap days: In Jan or Feb of year y count the leap years from 1600 to y-1, otherwise count the leap years from 1600 to y. Every fourth year is a leap year, except years divisible by 100 are not, except years divisible by 400 are.

Then you calculate days to your date x, days to a known date y with a known weekday, add days to y until the difference is a multiple of 7 days, then the day is the same.

More care needs to be taken if your date is not a Gregorian date but a Julian date. Leap day rules are different and the same day and month in the Julian and Gregorian calendar are different days. Gregorian calendar was first introduced in 1582, but Julian calendar stayed in use for a long time after that. For years BC remember there was no year 0BC. And 1000 or 2000 years from now you might expect some other leap days because 97 leap days every 400 years is not precise enough.

$\endgroup$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .