Skip to content

Instantly share code, notes, and snippets.

@MtnBiker
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MtnBiker/9063879 to your computer and use it in GitHub Desktop.
Save MtnBiker/9063879 to your computer and use it in GitHub Desktop.
Leap year w2e3 Ruby Course.
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