Method Deck / dates

Is it a leap year?

Determines whether a given year is a leap year under the Gregorian calendar rule.

Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.

Try it

Inputs

Outputs

Steps

  1. A year is a leap year if it is divisible by 4.
  2. Exception: a year divisible by 100 is NOT a leap year.
  3. Exception to the exception: a year divisible by 400 IS a leap year.
  4. Apply the rules in that order (or equivalently: divisible by 4 and not by 100, OR divisible by 400).

Constants

None.

Sources

Worked example and test vectors

NameInputsAnswer
worked example{"year":2000}yes
test vector: century exception{"year":1900}no
test vector: ordinary leap year{"year":2024}yes

Published card