Last active
August 29, 2015 13:56
-
-
Save MtnBiker/9063879 to your computer and use it in GitHub Desktop.
Leap year w2e3 Ruby Course.
This file contains hidden or 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
def not_leap_year(year) | |
puts "#{year} is not a leap year" | |
end | |
def leap_year(year) | |
if (year % 4) == 0 | |
if year % 100 == 0 | |
if year % 400 == 0 | |
puts "There are #{year*366*24*3600} seconds in the leap year #{year}" | |
else | |
not_leap_year(year) | |
end | |
else | |
not_leap_year(year) | |
end | |
else | |
not_leap_year(year) | |
end | |
end # leap_year | |
leap_year(2000) | |
leap_year(1900) | |
leap_year(25) | |
leap_year(1645) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment