Input
p := 100000
apr := 3.0
t := 30
Calcuation:
r := apr/100/12 # monthly interest rate
n := 12 * t # number of monthly payments
c(x) := 1 - (1 + r)^(-x)
m := p*r/c(n) # monthly payment
balance(i) := p*c(n-i)/c(n) # balance at the end of the ith month
principal(i) := balance(i-1) - balance(i) # principal part of the ith monthly loan payment
interest(i) := m - principal(i) # interest part of the ith month loan payment