Problem
A leap year is a year that includes February 29th, occurring every 4 years.
Given a specific year year, write a function solution that determines if the year is a leap year.
The rules for determining leap years are as follows:
- A year is a leap year if it is divisible by 4.
- However, a year is not a leap year if it is divisible by 100.
- A year is a leap year if it is divisible by 400.
Constraints
yearis a natural number between 1 and 4000 inclusive.- If
yearis a leap year, return the stringYES; otherwise, returnNO.
Test Case
| Test Case Number | year | return |
|---|---|---|
| 1 | 2000 | "YES" |
| 2 | 1900 | "NO" |
| 3 | 2024 | "YES" |
Explanation for Test Case 1
- When
year = 2000, it is divisible by 400, so it is a leap year. ReturnYES.
Explanation for Test Case 2
- When
year = 1900, it is divisible by 100 but not by 400, so it is not a leap year. ReturnNO.
Explanation for Test Case 3
- When
year = 2024, it is divisible by 4 but not by 100, so it is a leap year. ReturnYES.