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
year (integer, required) : Proleptic Gregorian calendar year
Outputs
is_leap: True if the year has a February 29
Steps
A year is a leap year if it is divisible by 4.
Exception: a year divisible by 100 is NOT a leap year.
Exception to the exception: a year divisible by 400 IS a leap year.
Apply the rules in that order (or equivalently: divisible by 4 and not by 100, OR divisible by 400).
Constants
None.
Sources
Calendars FAQ (US Naval Observatory / Astronomical Applications Department, 2026-09-30T19:41:35Z) - states the Gregorian leap-year rule: divisible by 4, except centuries, unless divisible by 400