ThisCalculator

Everyday

How Is Leap Year Calculated? The Gregorian Rule

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

How Is Leap Year Calculated? The Gregorian Rule

This leap-year calculator checks whether a year is a leap year using the Gregorian calendar rule. Enter a year to get a yes-or-no result, along with the rule that determines it.

Formula

A Gregorian year is a leap year if it is divisible by 4, except that a year divisible by 100 is not a leap year unless it is also divisible by 400. In symbols, for a whole-number year y:

  • Leap year when (y mod 4 = 0) and either (y mod 100 ≠ 0) or (y mod 400 = 0).
  • Otherwise, it is a common year with 365 days.

The calculator expresses this as a numeric test: (year / 4 = floor(year / 4)) * ((year / 100 != floor(year / 100)) + (year / 400 = floor(year / 400))). Here, year is the entered calendar year, with no physical unit. Each equality test is 1 when true and 0 when false; the result is 1 for a leap year and 0 for a common year. The expression uses whole-number years and is intended for positive year numbers.

Worked Example

Using the default year, 2024:

  1. 2024 / 4 = 506, a whole number, so the year passes the divisibility-by-4 test.
  2. 2024 / 100 = 20.24, not a whole number, so it is not a century year and qualifies as a leap year.
  3. The calculator expression gives 1 × (1 + 0) = 1.

Result: 2024 is a leap year. It has 366 days, including February 29.

Why Leap Years Are Needed

A calendar year is a count of whole days, but Earth’s seasonal cycle does not take exactly 365 days. The tropical year—the cycle most relevant to keeping seasons aligned with calendar dates—is about 365.2422 days. A calendar of exactly 365 days would fall behind that cycle by roughly a quarter of a day each year.

Adding a day from time to time corrects most of that drift. If every fourth year simply had an extra day, the average calendar year would be 365.25 days, slightly longer than the tropical year. The Gregorian calendar’s century exceptions make the long-term average more accurate.

How the Gregorian Rule Works

The rule is easiest to apply in order:

  • If the year is not divisible by 4, it is a common year.
  • If it is divisible by 4 but not by 100, it is a leap year.
  • If it is divisible by 100, check 400: it is a leap year only if divisible by 400.

“Divisible” means division leaves no remainder. For instance, 2024 ÷ 4 = 506 exactly, while 2023 ÷ 4 leaves a remainder. A year divisible by 100 is called a century year in this context; the extra check prevents too many leap days from accumulating.

Examples and Century-Year Exceptions

These examples show why the century condition matters:

  • 2023: Not divisible by 4, so it is a common year.
  • 2024: Divisible by 4 and not by 100, so it is a leap year.
  • 1900: Divisible by 100 but not by 400, so it was a common year.
  • 2000: Divisible by 400, so it was a leap year.
  • 2100: Divisible by 100 but not by 400, so it will be a common year.

A quick mental shortcut—“every four years”—works for many nearby years, but it fails at most century years. The 400-year check is not optional: it is the part that distinguishes 1900 from 2000.

Calendar Background and Practical Limits

The Gregorian calendar, introduced in 1582, refined the earlier Julian calendar’s leap-year pattern. Its rule gives 97 leap years in every 400-year cycle: the usual 100 years divisible by 4, minus three century years that are not divisible by 400. The average Gregorian year is therefore 365 + 97/400 days, or 365.2425 days.

This average is close to, but not exactly the same as, the length of the seasonal year. The calendar is a practical civil system, not a claim that Earth’s orbit repeats in a perfectly fixed number of days. Small differences accumulate over very long periods, and the Gregorian rule is not adjusted year by year to track every variation in Earth’s motion.

Also note that calendar systems differ. The rule in this calculator is for the Gregorian calendar, which is used for civil dates in much of the world. Historical dates may have been recorded under the Julian calendar or another system, and countries adopted the Gregorian calendar at different times. For a date near a historical calendar change, the place and calendar convention matter as well as the year.

Frequently Asked Questions

How do you calculate a leap year?
Check whether the year is divisible by 4. If it is also divisible by 100, it is a leap year only when divisible by 400. In compact form: divisible by 4, and either not divisible by 100 or divisible by 400.

Is every fourth year a leap year?
No. Most years divisible by 4 are leap years, but century years are excluded unless they are divisible by 400. That is why 1900 was not a leap year but 2000 was.

Is 2100 a leap year?
No. Although 2100 is divisible by 4 and by 100, it is not divisible by 400. Under the Gregorian rule, it will have 365 days.

Why does February have 29 days in a leap year?
The Gregorian calendar adds its correction day to February, the shortest month. February has 29 days in a leap year and 28 in a common year.

How many leap years are in 400 years?
There are 97 in a complete Gregorian 400-year cycle. The rule includes years divisible by 4 but removes three century years that are not divisible by 400.

Related

Formula used
in year | Year | - | 2024 | 1
out leap | Leap year | - | (year / 4 = floor(year / 4)) * ((year / 100 != floor(year / 100)) + (year / 400 = floor(year / 400))) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.