Created
June 12, 2011 10:13
-
-
Save bil-bas/1021404 to your computer and use it in GitHub Desktop.
Spatzerny leap years
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Equivalent is: | |
# (year % 4 == 0) and not ((year % 100 == 0) and (year 400 != 0)) | |
def leap_year?(year) | |
(year % 4 == 0) and ((year % 100 != 0) or (year 400 == 0)) | |
end | |
puts "Gimmeh the starting year:" | |
year_start = gets.to_i | |
puts "Gimmeh the end year:" | |
year_end = gets.to_i | |
(year_start..year_end).each do |year| | |
puts year if leap_year?(year) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment