Equation for Leap Year: Formula, Rules, and Examples
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.
This calculator determines whether a given year is a leap year using the standard Gregorian calendar rules. You enter a year, and the calculator tells you if it is a leap year, along with the number of days in that year (365 or 366). The equation is simple: a year is a leap year if it is divisible by 4, except if it is divisible by 100, unless it is also divisible by 400.
Formula
The leap year rule in the Gregorian calendar can be written as a single logical expression:
Leap Year = (year divisible by 4) AND ( (year not divisible by 100) OR (year divisible by 400) )
In symbols, for a year Y:
- If Y mod 4 = 0 AND (Y mod 100 ≠0 OR Y mod 400 = 0) → leap year (366 days)
- Otherwise → common year (365 days)
Here, “mod� means the remainder after division. For example, 2024 mod 4 = 0, so it passes the first test. 2024 mod 100 = 24 (not 0), so it passes the second test. Therefore 2024 is a leap year.
Worked Example
Using the default year 2024:
- Check divisibility by 4: 2024 ÷ 4 = 506, remainder 0 → yes.
- Check divisibility by 100: 2024 ÷ 100 = 20 remainder 24 → not divisible by 100.
- Since it is divisible by 4 and not divisible by 100, the rule says it is a leap year.
- Therefore 2024 has 366 days, and February has 29 days.
The calculator gives the same result: is_leap = 1, days = 366.
Why the Rule Exists
The Earth’s orbit around the Sun takes about 365.2422 days (the tropical year). A calendar with exactly 365 days would drift by about 0.2422 days each year, causing seasons to shift by about 1 day every 4 years. To correct this, the Julian calendar added a leap day every 4 years, giving an average year length of 365.25 days. That was slightly too long, causing a drift of about 11 minutes per year.
By the 16th century, the calendar had drifted by about 10 days. In 1582, Pope Gregory XIII introduced the Gregorian calendar, which refined the leap year rule to make the average year length 365.2425 days, very close to the actual tropical year. The extra rule about centuries (divisible by 100 but not by 400) removes three leap days every 400 years.
How to Apply the Equation
To decide if a year is a leap year, follow these steps in order:
- If the year is not divisible by 4 → not a leap year.
- If the year is divisible by 4 but not by 100 → leap year.
- If the year is divisible by 100 but not by 400 → not a leap year.
- If the year is divisible by 400 → leap year.
Examples:
- 2000: divisible by 4, by 100, and by 400 → leap year.
- 1900: divisible by 4 and by 100, but not by 400 → not a leap year.
- 2100: divisible by 4 and by 100, but not by 400 → not a leap year.
- 2024: divisible by 4, not by 100 → leap year.
Common Mistakes and Misconceptions
A frequent error is thinking every year divisible by 4 is a leap year. That works for most years, but fails for century years like 1900 and 2100. Another mistake is forgetting the 400 rule: some people assume all century years are not leap years, but 2000 was a leap year because it is divisible by 400.
Also, the leap year rule applies to the Gregorian calendar, which is the standard civil calendar in most of the world today. The Julian calendar (used before 1582 and still used by some Orthodox churches) has a simpler rule: every year divisible by 4 is a leap year. So a year like 1900 is a leap year in the Julian calendar but not in the Gregorian.
Limits of the Formula
The Gregorian rule is accurate to about one day in 3,300 years, but it is still an approximation. The exact tropical year is 365.2422 days, while the Gregorian average is 365.2425 days. The small difference accumulates slowly. Some proposals, such as the Revised Julian calendar, use a more complex rule to be even more precise, but they are not widely adopted.
For historical dates before 1582, the Gregorian rule is often applied retroactively (the proleptic Gregorian calendar), but you should be aware that the Julian calendar was in use in many places before that. When working with historical dates, always check which calendar system is being used.
Why It Matters
Leap years keep the calendar aligned with the seasons, which is critical for agriculture, religious holidays (like Easter, which is tied to the spring equinox), and civil scheduling. Without leap days, the calendar would drift so that after about 750 years, summer in the Northern Hemisphere would start in December. The leap year rule is also used in computing date differences, calculating interest, and determining anniversaries.
Frequently Asked Questions
Is 2024 a leap year?
Yes, 2024 is a leap year. It is divisible by 4 and not by 100, so it has 366 days with February 29.
Why is 1900 not a leap year?
1900 is divisible by 4 and by 100, but not by 400. According to the Gregorian rule, century years are leap years only if they are divisible by 400. Since 1900 is not, it is a common year.
Why is 2000 a leap year?
2000 is divisible by 100 but also by 400, so the exception applies and it is a leap year. This is why the year 2000 had February 29.
What happens if we don’t have leap years?
Without leap years, the calendar would drift about 0.2422 days per year. Over 100 years, that’s about 24 days, so seasons would shift significantly. After a few centuries, the calendar would no longer match the seasons.
Is there a leap year every 4 years?
Almost, but not exactly. The 4-year cycle is interrupted for century years not divisible by 400. For example, the gap between 1896 and 1904 is 8 years because 1900 was not a leap year.
Does the leap year rule apply to the Julian calendar?
No, the Julian calendar has a simpler rule: every year divisible by 4 is a leap year. This makes the Julian calendar slightly less accurate than the Gregorian.
Related
Formula used
in y | Year | year | 2024 | 0 out is_leap | Leap year? | - | if(floor(y/4)*4 == y and (floor(y/100)*100 != y or floor(y/400)*400 == y), 1, 0) | 0 out days | Days in year | days | 365 + if(floor(y/4)*4 == y and (floor(y/100)*100 != y or floor(y/400)*400 == y), 1, 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.