Check if a given year is a leap year, and find the next and previous leap year.
The Gregorian calendar (used in most of the world today) uses this rule to determine whether a year is a leap year:
This slightly convoluted rule fine-tunes the calendar so it stays as closely synchronized as possible with Earth's actual orbital period around the sun, which is about 365.2422 days — not exactly 365.25 days, which a simple "every 4th year" rule would assume.
Examples: 2024 is a leap year (divisible by 4, not by 100). 1900 was not a leap year (divisible by 100, but not by 400). 2000 was a leap year (divisible by 400).
Because Earth's actual orbital period around the sun is about 365.2422 days, not exactly 365. Without leap years, the calendar would slowly but surely drift out of sync with the seasons — after a few hundred years, summer would fall in the middle of winter on the calendar.
Because the "every 4th year" rule alone would produce slightly too many leap years compared to Earth's actual orbital period. The exception for century years not divisible by 400 (like 1700, 1800, 1900) corrects for this small excess error.
Yes. Even though 2000 is a century year (divisible by 100), it's also divisible by 400, and was therefore a leap year — the same applies to 1600 and will apply to 2400.