#539 · Loops · Beginner · 30 XP · about 5 min
Write count_leap_years(start, end) that returns how many leap years there are from the year start to the year end, counting both of them. If start is later than end, there are none, so return 0.
The leap year rules:
count_leap_years(2000, 2010) # returns 3 count_leap_years(1896, 1904) # returns 2 count_leap_years(2021, 2023) # returns 0
From 1896 to 1904 the leap years are 1896 and 1904: 1900 is divisible by 100 but not by 400, so it was not one.
Both years are from 1 to 9999.
First solves only, ranked by stars and then time.