FIND LEAP YEAR OR NOT
Leap Year: A Calendar Phenomenon
A leap year is a year that has one extra day, making it 366 days instead of the usual 365. This additional day is added to the month of February, making it 29 days long instead of 28. Leap years occur to align our calendar year with the Earth's orbit around the Sun, which takes approximately 365.25 days.
How to Identify a Leap Year?
A year is a leap year if it satisfies these conditions:
- It is divisible by 400.
Example: 1600, 2000 (leap years). - It is divisible by 4 but not divisible by 100.
Example: 2024, 2028 (leap years).
Years that don’t meet these criteria are not leap years. For instance, 1900 and 2100 are not leap years as they are divisible by 100 but not by 400.
import java.util.*;
class HelloWorld {
public static void main(String[] args) {
int n=sc.nextInt();
if(n%400==0){
System.out.print("yes");
}
else if(n%4==0 && n%100!=0){
System.out.print("yes");
}
else{
System.out.print("no");
}
System.out.print(n%400==0?"yes":(n%4==0 && n%100!=0)?"yes":"no");
}
}
Why Do We Need Leap Years?
Without leap years, our calendar would drift over time, misaligning seasons with their corresponding months. The leap year adjustment keeps the calendar in sync with Earth's orbit.
Fun Facts About Leap Years
- People born on February 29, known as "leaplings," celebrate their birthday every four years!
- Leap years occur approximately once every four years.
No comments:
Post a Comment