Skip to content

Instantly share code, notes, and snippets.

@christonog
Created April 20, 2012 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christonog/2430185 to your computer and use it in GitHub Desktop.
Save christonog/2430185 to your computer and use it in GitHub Desktop.
mortgage
puts "I want to pay x amount per month. How much house can I afford?"
each_payment = gets.chomp.to_i
interest_rate = 0.045
interest_rate_per_period = interest_rate/12
number_of_payments = 360
loan_amount = (each_payment/interest_rate_per_period)*(1-(1+interest_rate_per_period)**-number_of_payments)
puts loan_amount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment