Leap Year Checker
Determine whether a given year is a 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 they're also divisible by 400.
Approach: combine the three checks with and/or: (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0).
Input: One line: a year (a whole number).
Output: One line: <year> is a leap year or <year> is not a leap year.
2024
2024 is a leap year
- 1 <= year <= 9999
Hint 1
A year divisible by 4 is usually a leap year...
Hint 2
...unless it's also divisible by 100, in which case it must also be divisible by 400.
Hint 3
Combine the checks with and / or rather than nesting several if statements.
A year is a leap year when (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) — divisible by 4 covers most leap years, the % 100 check excludes century years, and the % 400 check adds century years like 2000 back in.