ThisCalculator

Everyday

Leap Year Formula: How to Calculate

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.

Leap Year Formula: How to Calculate

This calculator tells you whether a given year is a leap year using the standard Gregorian calendar rule. You enter a year, and it returns “Leap Year” or “Common Year” along with the number of days in that year. The formula is simple: a year is a leap year if it is divisible by 4, except that century years (ending in 00) are leap years only if they are also divisible by 400.

Formula

The leap year rule in the Gregorian calendar can be written as:

Leap year if: (year divisible by 4) AND (year not divisible by 100) OR (year divisible by 400)

In symbols: L = (Y % 4 == 0 AND Y % 100 != 0) OR (Y % 400 == 0)

  • Y – the year (integer, e.g., 2024)
  • % – modulus operator, gives the remainder of division
  • L – result: true (leap year) or false (common year)

The rule exists to keep the calendar aligned with Earth’s orbit around the Sun, which takes about 365.2422 days. Adding a day every 4 years gives an average year of 365.25 days, which is too long. Dropping leap years at century marks (except those divisible by 400) brings the average down to 365.2425 days, very close to the actual value.

Worked Example

Let’s test the default year, 2024, with the formula.

  1. Check divisibility by 4: 2024 ÷ 4 = 506, remainder 0 → divisible.
  2. Check divisibility by 100: 2024 ÷ 100 = 20, remainder 24 → not divisible.
  3. Since it’s divisible by 4 and not by 100, the first part is true. The OR condition is satisfied.
  4. Result: 2024 is a leap year (366 days).

Now test a century year, 1900:

  1. Divisible by 4? Yes (1900 ÷ 4 = 475).
  2. Divisible by 100? Yes (1900 ÷ 100 = 19).
  3. First part fails because it’s divisible by 100.
  4. Divisible by 400? No (1900 ÷ 400 = 4.75).
  5. Result: 1900 is not a leap year.

The calculator uses the same logic and for 2024 outputs “1” (true) and 366 days.

How to Determine a Leap Year Step by Step

If you want to check a year manually, follow these steps:

  1. Divide the year by 4. If the remainder is not 0, it’s a common year (365 days).
  2. If the year is divisible by 4, check if it’s divisible by 100. If not, it’s a leap year.
  3. If it’s divisible by 100, check if it’s also divisible by 400. If yes, it’s a leap year; if no, it’s a common year.

For example, 2020: divisible by 4, not by 100 → leap year. 2000: divisible by 4, by 100, and by 400 → leap year. 2100: divisible by 4 and 100, but not by 400 → common year.

This rule applies to years in the Gregorian calendar, which is the standard civil calendar in most of the world. For the Julian calendar (used before 1582 and still by some Orthodox churches), the rule is simpler: every year divisible by 4 is a leap year. That calendar drifts more over time.

Why We Need Leap Years

The Earth takes approximately 365.2422 days to orbit the Sun. A calendar with 365 days would drift about 0.2422 days per year, meaning after 100 years the seasons would shift by about 24 days. To compensate, we add an extra day every four years (leap day, February 29). However, adding a day every four years overcorrects because 365.25 days is slightly longer than the true year. The century rule fixes that overcorrection, making the average calendar year 365.2425 days, which is accurate enough that the remaining error is only about one day every 3,300 years.

Common Mistakes and Misconceptions

  • Forgetting the century rule: Many people assume every year divisible by 4 is a leap year. That’s true for most years, but not for century years like 1900 or 2100.
  • Applying the rule to the Julian calendar: If you’re working with historical dates before 1582, the Julian rule (every 4 years) applies, not the Gregorian rule.
  • Using the year 0: There is no year 0 in the Gregorian calendar. The year before 1 AD is 1 BC. When calculating leap years for ancient dates, be careful.
  • Confusing leap year with leap second: Leap seconds are added to atomic time to keep it in sync with solar time, but they are unrelated to leap years.

Leap Year in Programming and Spreadsheets

In many programming languages, you can implement the leap year check with a single expression. In Excel or Google Sheets, the formula is:

=IF(OR(MOD(A1,400)=0,AND(MOD(A1,4)=0,MOD(A1,100)<>0)),"Leap","Common")

In Python, you can write:

def is_leap(year): return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)

These implementations follow the same logic. The main pitfall is forgetting the parentheses: the condition must group the AND and OR correctly. The rule is: (divisible by 4 AND not divisible by 100) OR (divisible by 400).

Limitations and Edge Cases

The Gregorian rule is accurate for most practical purposes, but it’s not perfect. The true tropical year is about 365.24219 days, so the Gregorian calendar gains about 0.00031 days per year, which adds up to roughly one day every 3,300 years. Some proposed reforms, like the Revised Julian calendar, use a more complex rule, but the Gregorian rule is the global standard.

For very large years (e.g., 100000), the formula still works, but the concept of a year becomes less meaningful because the Earth’s rotation and orbit change over long timescales. Also, note that the Gregorian calendar was adopted at different times in different countries; for example, Britain adopted it in 1752, so dates between 1582 and 1752 may be ambiguous depending on the country.

Frequently Asked Questions

Is 2000 a leap year?

Yes, 2000 is a leap year because it is divisible by 400. It was a century year, but the 400 rule makes it a leap year. The next century leap year will be 2400.

Is 1900 a leap year?

No, 1900 is not a leap year. It is divisible by 100 but not by 400, so the century exception applies. This is the most common example of a year that many people mistakenly think is a leap year.

Why does February have 28 days in a common year?

February originally had 28 days in the Roman calendar. When the leap day was added, it was placed in February, giving it 29 days in leap years. This tradition carried into the Gregorian calendar.

How do I know if a year is a leap year without a calculator?

Use the rule: if the year ends in 00, check if it’s divisible by 400 (e.g., 2000, 2400). Otherwise, just check if it’s divisible by 4. For example, 2024 is divisible by 4, so it’s a leap year.

Does the leap year rule apply to the Islamic or Chinese calendars?

No, those calendars use different systems. The Islamic calendar is lunar and has 354 or 355 days; it adds an extra day in a 30-year cycle. The Chinese lunisolar calendar adds a leap month roughly every 3 years. The Gregorian rule applies only to the Gregorian and Julian calendars.

Related

Formula used
in y | Year | - | 2024 | 1
out is_leap | Leap Year? | - | (y % 4 == 0 && y % 100 != 0) || y % 400 == 0 | 0
out days | Days in Year | - | 365 + ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) | 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.