Skip to content

Instantly share code, notes, and snippets.

@rbclark
Created November 3, 2022 23:12
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 rbclark/3d6947f693c911f8419ca5ecde5e7e00 to your computer and use it in GitHub Desktop.
Save rbclark/3d6947f693c911f8419ca5ecde5e7e00 to your computer and use it in GitHub Desktop.
require "readline"
CURRENT_INTEREST_RATE=6.97/100
print "Input home value: "
value = gets.chomp.to_i
print "Input interest rate: "
rate = gets.chomp.to_f/100
i = (1+rate/12)**(12/12)-1
annuity = (1-(1/(1+i))**360)/i
payment = value/annuity
puts "\n$%.2f per month" % [payment]
current_i = (1+CURRENT_INTEREST_RATE/12)**(12/12)-1
current_annuity = (1-(1/(1+current_i))**360)/current_i
current_value = current_annuity * payment
puts "For a 30 year mortgage the equivalent house value at current rates is: $%.2f" % [current_value]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment