What is a leap day or leap year?
A leap year is a calendar year with an extra day compared to a typical year. And that extra or additional day, i.e., February 29, is called the leap day.
Common/Typical Year (y)=365 solar days
Solar/Tropical/Astronomical Year (Y)=365.2425 solar days
Difference (Δy)=Y-y=0.2425 solar days
Adjustment: 4*Δy=0.97=1–0.03 (+1 if divisible by 4)
Over-accumulation: 100*Δy=24.25=(25–1)+0.25 (again -1 if divisible by 100)
Compensation: 400*Δy=97=4*(25–1)+1 (again +1 if divisible by 400)
Get Pustam Raut (पुस्तम राउत)’s stories in your inbox
Join Medium for free to get updates from this writer.
Using logical and modulo operators, the year n is said to be a leap year if and only if (n mod 4=0)∧((n mod 100≠0)∨(n mod 400=0)). In other words, a year is a leap year if it is evenly divisibly 4, except for years that are evenly divisible by 100 but not evenly divisible by 400. For example, 2024 and 2028 are leap years, 2100 and 2200 are not, but 2400 and 2800 are.
Now, let’s calculate the number of days in an arbitrary year. Take 2300. 2300 is divisible by both 4 and 100, but not by 400. So, the number of days in the year 2050 will be 365+1–1+0=365 solar days. In general, the number of days in the year n will be 365+E(n,4)-E(n,100)+E(n,400), where E(a,b) is a function (introduced by me) that returns 1 when a is divisible by b, otherwise 0.
This is our clever method to ensure that our calendar stays aligned with our seasons or Earth’s orbit over time. If nothing were done about this discrepancy, our calendar would slowly drift out of sync with the Earth’s orbit and seasons. After 100 years, we would be off by about 25 days! So, to fix this, we add an extra day, February 29, to the calendar every four years, with the exception that a year evenly divisible by 100 is not a leap year unless it is also evenly divisible by 400 (as shown in the calculations).
Moreover, the intricate balance of factors that make Earth habitable is awe-inspiring. Earth's suitability for life is remarkable from its axial tilt to its distance from the Sun, the abundance of water, and the composition of its atmosphere. I find inspiration in contemplating the beauty and complexity of our planet and attribute it to the wonders of nature. It’s a testament to the fascinating interplay of physical and environmental processes that have shaped Earth into the diverse and vibrant world we call home.
Below is a Python code snippet to determine whether a given year is a leap year or not:
def is_leap_year(year):
# Leap year if divisible by 4
if year % 4 == 0:
# Unless it's divisible by 100 but not by 400
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
else:
return True
else:
return False
# Test the function
year = int(input("Enter a year: "))
if is_leap_year(year):
print(year, "is a leap year")
else:
print(year, "is not a leap year")C code to determine whether a given year is a leap year or not:
#include <stdio.h>
int is_leap_year(int year) {
// Leap year if divisible by 4
if (year % 4 == 0) {
// Unless it's divisible by 100 but not by 400
if (year % 100 == 0) {
if (year % 400 == 0)
return 1;
else
return 0;
} else {
return 1;
}
} else {
return 0;
}
}
int main() {
int year;
printf("Enter a year: ");
scanf("%d", &year);
if (is_leap_year(year))
printf("%d is a leap year.\n", year);
else
printf("%d is not a leap year.\n", year);
return 0;
}C++ code to determine whether a given year is a leap year or not:
#include <iostream>
bool is_leap_year(int year) {
// Leap year if divisible by 4
if (year % 4 == 0) {
// Unless it's divisible by 100 but not by 400
if (year % 100 == 0) {
if (year % 400 == 0)
return true;
else
return false;
} else {
return true;
}
} else {
return false;
}
}
int main() {
int year;
std::cout << "Enter a year: ";
std::cin >> year;
if (is_leap_year(year))
std::cout << year << " is a leap year." << std::endl;
else
std::cout << year << " is not a leap year." << std::endl;
return 0;
}



