Go about finding how many years between 1 and 2000 were leap years

discrete mathematicsnumber theory

Question:

Assuming x represents the value of the year. If x is divisible by 4, then the year is determined as being leap. But, if x is divisible by 100, then, the year would be determined as not being leap, unless it would be divisible 400, which would then imply it being leap. How many years between 1 and 2000 would be leap?

Here is what I got:

Number of years divisible by 4 = $\frac{1996-4}{4}+1$ = 499

Number of years divisible by 100 = $\frac{1900-100}{100}+1$ = 19

Number of years divisible by 400 = $\frac{1600-400}{400}+1$ = 4

Number of years between 1 and 2000 would be leap = 499 – 19 + 4 = 484

Could anyone assist me into reformatting/ presenting my answers into a more mathematically proper presentation?

Best Answer

Prior to the Gregorian calendar, a leap year would occur once every four years. In this case we have $$j(x)=\left\lfloor\frac{x}{4}\right\rfloor$$ Once the Gregorian calendar was adopted, which occurred in 1582, we have that every 400 years contains 97 leap years. Hence $$g(x)=\left\lfloor\frac{97x}{400}\right\rfloor$$ In this case we also have to account for the 12 leap years that occurred prior to 1582. Kudos to egreg for pointing this out. $$g(x)=\left\lfloor\frac{97x}{400}\right\rfloor+12$$ Since 4 AD was not a leap year, we must substract one from the end result in both scenarios $$j(x)=\left\lfloor\frac{x}{4}\right\rfloor-1$$ $$g(x)=\left\lfloor\frac{97x}{400}\right\rfloor+11$$ Ultimately what you're looking for is this $$f(x)=\left\{\begin{array}{ll} 0, & x\lt 4 \\ \left\lfloor\frac x4\right\rfloor-1, & 4\le x\lt 1582 \\ \left\lfloor\frac{97x}{400}\right\rfloor+11, & x\ge 1582 \end{array}\right.$$ Where $x$ is an integer that represents a given year in the common era. Since we seek the total number of leap years between 1 and 2000, we have $$f(1999)=495$$ And we're done. I hope this helps you understand.