Skip to content

Instantly share code, notes, and snippets.

@makoru-hikage
Last active May 23, 2023 14:20
Show Gist options
  • Save makoru-hikage/22120538b27a22b869cbfaca966f9abd to your computer and use it in GitHub Desktop.
Save makoru-hikage/22120538b27a22b869cbfaca966f9abd to your computer and use it in GitHub Desktop.
A leap year is divisible by 4, not divisible by 100 only, and divisible by 400.
#!/usr/bin/python
def is_leap_year (n):
if n % 100 == 0:
dividedBy100 = n / 100
if dividedBy100 % 4 == 0:
return True
else:
return n % 4 == 0
# From 1900 to 2000
a = [x + 1900 for x in range(101) if is_leap_year(x + 1900)]
print(len(a))
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment