Created
June 29, 2015 03:04
-
-
Save hellobelda/c70284ca063ea9677045 to your computer and use it in GitHub Desktop.
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
# Write a function that returns true or false depending on | |
# whether its input integer is a leap year or not. | |
# | |
# A leap year is defined as one that is divisible by 4, | |
# but is not otherwise divisible by 100 unless it is | |
# also divisible by 400. | |
# | |
# For example, 2001 is a typical common year and 1996 | |
# is a typical leap year, whereas 1900 is an atypical | |
# common year and 2000 is an atypical leap year. | |
def leap_year?(input_integer) | |
(input_integer % 4 == 0) && divisible_logic?(input_integer) | |
end | |
def divisible_logic?(input_integer) | |
if input_integer % 100 > 0 | |
return true | |
end | |
if input_integer % 400 == 0 | |
return true | |
end | |
false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment