Skip to content

Instantly share code, notes, and snippets.

@tmountain
Created May 5, 2017 18:24
Show Gist options
  • Save tmountain/e944ff40f3f1ad3fb3d1f0cde3a6f30f to your computer and use it in GitHub Desktop.
Save tmountain/e944ff40f3f1ad3fb3d1f0cde3a6f30f to your computer and use it in GitHub Desktop.
def interest(principal, rate, times, years)
principal * (1 + rate.to_f/times.to_f) ** (times.to_f * years.to_f)
end
1.upto(50) do |y|
puts sprintf("%.02f", interest(1000, 0.05, 1, y))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment