Skip to content

Instantly share code, notes, and snippets.

@kazad
Created April 15, 2026 20:31
Show Gist options
  • Select an option

  • Save kazad/08296124415e06cca280534c20aa01fa to your computer and use it in GitHub Desktop.

Select an option

Save kazad/08296124415e06cca280534c20aa01fa to your computer and use it in GitHub Desktop.
mortgage
# Loan Details
home price = $450,000
down payment = 20%
interest rate = 6.5%
term = 30 //@suffix(years)
# Computed
down amount = $home price * down payment
loan amount = $home price - down amount
r = interest rate / 12 //@hidden
n = term * 12 //@hidden
monthly payment = $round(loan amount * (r * (1+r)^n) / ((1+r)^n - 1), 2)
# Key Numbers
$monthly payment //@hero
total cost = $round(monthly payment * n) //@hero
total interest = $round(total cost - loan amount) //@label(Total Interest Paid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment