Is It a Leap Year?

Published by Deep Xavier in

In a calendar year, it is exactly 365.25 days. But, eventually, this will lead to confusion because humans normally count by exact divisibility of 1 and not with decimal points. So, to avoid the latter, it was decided to add up all 0.25 days every four-year cycle and give that year 366 days (including February 29 as an intercalary day) and call it a leap year. The other three years in the four-year cycle would only contain 365 days and wouldn't be leap years.

In this challenge, though quite repetitive, we'll take it to a new level, where you are to determine if it's a leap year or not without the use of the Date() class, switch statements, if blocks, if-else blocks or ternary operation (x == 1 ? a : b) nor the logical operators AND (&&) and OR (||) with the exemption of the NOT (!) operator.

Return true if it's a leap year, false otherwise.

Examples

isLeapYear(1979) ➞ false

isLeapYear(2000) ➞ true

isLeapYear(1521) ➞ false

isLeapYear(1996) ➞ true

isLeapYear(1800) ➞ false

isLeapYear(2016) ➞ true

Notes

You can't use the Date class, switch statements, if statements in general, the ternary operator, or the logical operators (&&, ||).

Watch a quick demo on how Edabit works.