Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is_Leap_Year #28

Closed
Khusro-S opened this issue Dec 28, 2024 · 0 comments · Fixed by #47
Closed

Is_Leap_Year #28

Khusro-S opened this issue Dec 28, 2024 · 0 comments · Fixed by #47
Assignees

Comments

@Khusro-S
Copy link
Member

Khusro-S commented Dec 28, 2024

Leap Year Problem

This problem involves determining whether a given year is a leap year based on the rules defined in the Gregorian calendar. In a leap year, an extra day (February 29) is added to the calendar to account for the fact that a year is not exactly 365 days, but approximately 365.25 days. The task is to implement a function is_leap(year) that takes an integer year as input and returns True if the year is a leap year and False otherwise.

Key Considerations:

Leap Year Rules:

  1. If the year is divisible by 4, it's usually a leap year.
  2. However, if the year is also divisible by 100, it is not a leap year, unless:
  3. The year is divisible by 400. If it is, then it is a leap year.
    In short, If the year is divisible by 4, but not divisible by 100, or if it is divisible by 400, then it is a leap year.

This logic means:

  • Years like 2000 and 2400 are leap years because they are divisible by 400.
  • Years like 1800, 1900, 2100, 2200, 2300, and 2500 are not leap years because they are divisible by 100 but not by 400.
  • Years like 1996, 2004, and 2008 are leap years because they are divisible by 4 but not by 100.

Constraints:

  • The input year is a positive integer representing a year in the Gregorian calendar.
  • The year can be any valid integer that represents a calendar year, including edge cases like very old years or very large years.
  • The function must efficiently handle the input year and output the correct Boolean value.

Sample Test Cases:

Test Case 1:

  • Input: 1990
  • Output: False
  • Explanation: 1990 is not divisible by 4, hence it is not a leap year.

Test Case 2:

  • Input: 2000
  • Output: True
  • Explanation: 2000 is divisible by 400, so it is a leap year.

Test Case 3:

  • Input: 2100
  • Output: False
  • Explanation: 2100 is divisible by 100 but not by 400, so it is not a leap year.

Test Case 4:

  • Input: 2004
  • Output: True
  • Explanation: 2004 is divisible by 4 but not by 100, so it is a leap year.
@Khusro-S Khusro-S self-assigned this Dec 28, 2024
@Khusro-S Khusro-S moved this from TODO to DOING in ET6 Foundations Group 24 Dec 28, 2024
@Khusro-S Khusro-S moved this from DOING to READY FOR REVIEW in ET6 Foundations Group 24 Dec 29, 2024
@Khusro-S Khusro-S linked a pull request Dec 29, 2024 that will close this issue
40 tasks
@Khusro-S Khusro-S moved this from READY FOR REVIEW to UNDER REVIEW in ET6 Foundations Group 24 Jan 2, 2025
@Khusro-S Khusro-S moved this from UNDER REVIEW to DONE in ET6 Foundations Group 24 Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

1 participant