Skip to content

Instantly share code, notes, and snippets.

@stomatocode
Created April 7, 2013 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stomatocode/5333048 to your computer and use it in GitHub Desktop.
Save stomatocode/5333048 to your computer and use it in GitHub Desktop.
def leap_year?(year)
if year % 4 == 0
puts true
elsif year % 100 == 0
puts false
elsif year % 100 == 0 && year % 400 == 0
puts true
elsif year % 4 == 0 && year % 100 == 0 && !(year % 400 == 0)
puts false
else
puts false
end
end
puts leap_year?(1988)
puts leap_year?(1989)
puts leap_year?(1998)
puts leap_year?(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment