How it works
A leap year occurs every 4 years to keep the calendar aligned with Earth's 365.2422-day orbit around the sun. The rule has an exception: century years (divisible by 100) are not leap years unless also divisible by 400, which fine-tunes the correction.
leap = (year % 4 == 0 AND year % 100 ≠ 0) OR (year % 400 == 0)
Worked example
Is 2024 a leap year?
- Check if divisible by 4: 2024 ÷ 4 = 506 (yes).
- Check if divisible by 100: 2024 ÷ 100 = 20.24 (no, remainder 24).
- Since 2024 is divisible by 4 and not divisible by 100, it is a leap year.
- February has 29 days; next leap year is 2028; previous is 2020.
2024 is a leap year.
Year 1900: divisible by 4 (1900 ÷ 4 = 475) and divisible by 100 (1900 ÷ 100 = 19), but not divisible by 400 (1900 ÷ 400 = 4.75). So 1900 is not a leap year, despite being divisible by 4.
Year 2000: divisible by 4, divisible by 100, and divisible by 400 (2000 ÷ 400 = 5). So 2000 is a leap year — the "divisible by 400" rule overrides the century exception.
Common questions
What's the actual leap year rule?
A year is a leap year if it's divisible by 4 — except century years (divisible by 100), which are only leap years if also divisible by 400. That's why 2000 was a leap year but 1900 and 1800 were not.
Why do we need leap years at all?
Earth's orbit around the sun takes about 365.2422 days, not exactly 365 — without an extra day roughly every 4 years, the calendar would slowly drift out of sync with the seasons, shifting by about a day every 4 years.
Why does the century rule exist if we already add a day every 4 years?
Adding a day every single 4 years slightly overcorrects — it's about 0.0078 days too many per year. Skipping the leap day in 3 out of every 4 century years (keeping it only when divisible by 400) brings the average calendar year much closer to the true 365.2422-day solar year.