Skip to content

Instantly share code, notes, and snippets.

@MrBri
Created May 27, 2012 20:38
Show Gist options
  • Save MrBri/2815837 to your computer and use it in GitHub Desktop.
Save MrBri/2815837 to your computer and use it in GitHub Desktop.
Challenge 1 in the forums from Ruby Core at rubylearning.org
def age(sec)
years_float = sec.to_f / 60 / 60 / 24 / 365
years_int = sec / 60 / 60 / 24 / 365
months = (years_float - years_int) * 12
puts "I'm #{years_int} years and #{months.to_i} months old."
end
age 979000000
age 2158493738
age 2461144023
age 1270166272
age 1025600095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment