8 years without a leap year
How would you know if a given year is a leap year? The first strategy that I adopted was the following:
- Recall one year that was leap, fex I know that 2012 or 2020 were leap
- Add/ subtract 4 until I get to the desired year
For example, if I wanted to know if 1994 was leap I would do the following $2012 \rightarrow 2008 \rightarrow 2004 \rightarrow 2000 \rightarrow 1996 \rightarrow 1992$, hence $1994$ was not a leap year.
Some years later, when I was taught the power of division I realized that what I was doing was finding if the number was divisible by four, so my strategy morfed into the following algorithm:
- Check if the number is pair
- If so, divide by two
- Check if the result is pair
- If so the year is leap
Or in pseudocode
IF (year MOD 2 == 0) THEN
IF ((year DIV 2) MOD 2 == 0) THEN
RETURN TRUE
ELSE
RETURN FALSE
END IF
ELSE
RETURN FALSE
END IF
I was happy with this algorithm and used it everytime I needed to know if a year was leap. I was convinced of this algorithm until today, when I was implementing it in Cursor and I got the following tab suggestion

At first I thought Wow, AI sometimes does some really weird stuff, but a few seconds later I remembered that Cursor tab suggestions are trained into millions of lines of code, and that if it was suggesting this, there might be a reason. I then proceeded to google how to determine if a year is a leap year, and much to my surprise, my beloved algorithm was wrong.
For a year to be leap it has to be divisible by four AND either divisible by 400 or not divisible by 100. This second condition only affects centuries, and means that 2000 is a leap year, but 2100, 2200 and 2300 are not, the same way as 1900, 1800 and 1700 aren’t either.
I was completely taken aback by this fact, I didn’t know and wouldn’t have ever guessed if not for Cursor tab suggestions. In fact this might have prevented a small imprecision in my code that otherwise would have stayed there (because no amount of revisions would have made me check the criterion of what a leap year was).
Also it feels very strange to have periods where you go on for eight years without a leap year, fex between 1896 and 1904. I wonder if I had been born in 1903 rather than 2003 I would have had this extra condition present.