Problem
A year divisible by 4 is a leap year unless it is also divisible by 100. Years divisible by 400 are leap years despite that exception. Apply this arithmetic rule to every allowed input year.
Implement leap_year(year).
Input
year: The year to check.
Output
Return true for a leap year and false otherwise.
Constraints
1 ≤ year ≤ 9999.
Examples
Input:
year = 2024
Expected output:
expected = True
Input:
long long year = 2024;
Expected output:
bool expected = true;
Input:
long year = 2024;
Expected output:
bool expected = true;
Explanation
2024 is divisible by 4 and not by 100.
Input:
year = 2100
Expected output:
expected = False
Input:
long long year = 2100;
Expected output:
bool expected = false;
Input:
long year = 2100;
Expected output:
bool expected = false;
Explanation
2100 is divisible by 100 but not by 400, so the century exception applies.
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.