Skip to content

Instantly share code, notes, and snippets.

@yasalmasri
Created December 13, 2023 21:51
Show Gist options
  • Save yasalmasri/b92d6b9e2cdbd61483f0b82021567ed0 to your computer and use it in GitHub Desktop.
Save yasalmasri/b92d6b9e2cdbd61483f0b82021567ed0 to your computer and use it in GitHub Desktop.
compound_interest.rb
require 'amazing_print'
def interest(amount:, rate:, months:, years:)
a = amount
1.upto(years) do
1.upto(months) do |month|
a += a * rate/months
a += amount
end
end
a.ceil(2)
end
ap interest(amount: 10000, rate: 0.12, months: 12, years: 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment