Inspectable Arithmetic for the Loan Repayment Calculator
Version 1.1
Last verified: May 2026
Transparent arithmetic is the operating system of this calculator.
This document publishes the formulae, computational structure, and assumptions used to generate the outputs displayed on the
Loan Repayment Calculator page.
No opinions. No hidden assumptions. Just arithmetic.
Purpose
The calculator models a fixed-rate, fully amortizing loan with a constant payment each period. It computes the payment per period,
total interest, total paid, number of payments, an amortization schedule, and chart data derived from that schedule.
Definitions
Let:
- P = loan amount (principal), as entered
- rpct = nominal annual interest rate in percent, as entered
- r = rpct / 100 = annual rate as a decimal
- m = payments per year (12, 26, or 52)
- i = r / m = interest rate per payment period
- T = amortization term in years, as entered
- N = round(T × m) = total number of payments
- A = payment amount per period (constant when r and N are fixed)
- Bk = remaining balance immediately after payment k (B0 = P)
Formulae
1. Number of payments
N = round(T · m)
If T · m is not an integer, N is the nearest integer (same as the live engine).
2. Payment per period
If r = 0 (or equivalently rpct = 0):
A = P / N
Otherwise:
A = P · i(1 + i)N / ((1 + i)N − 1)
Standard fixed-rate, fully amortizing payment formula with periodic rate i and N payments.
3. Amortization step (for k = 1 … N)
Starting with B0 = P, for each period k:
Interestk = Bk−1 · i
Principalk = A − Interestk
Bk = Bk−1 − Principalk
Each row in the on-page table uses these values. The payment column is A for every period (before display rounding).
4. Totals
Total paid = Σk=1…N A = N · A
Total interest = Σk=1…N Interestk
Headline totals match the sums of the schedule rows (within cent rounding on display).
5. Final balance and clamping
The engine advances the balance with full floating-point precision, then may clamp the final remaining balance to zero if a tiny
negative value appears due to rounding (magnitude under about one cent). This matches the QA invariants documented in
engine.js.
Payment frequency labels
Period labels in the schedule use “Month k” when m = 12, and “Week k” when m = 26 or 52 (biweekly and weekly). This is a display
convention only; the mathematics uses m as payments per year regardless of label.
Assumptions
- Nominal annual rate is converted to a periodic rate by dividing by m (no separate compounding convention).
- Interest rate is constant for the full amortization horizon.
- Payments are equal and occur exactly m times per year with no skipped or irregular payments.
- No fees, penalties, insurance, taxes, or extra payments are modeled.
- Display values are rounded to cents where shown; internal steps use JavaScript floating-point arithmetic.
Implementation
The live schedule and headline outputs are produced by computeLoanSchedule in
/calculators/loan-repayment/engine.js. The UI binds those results in ui.js.
If any discrepancy is identified between this documentation and the live engine, the engine’s arithmetic is the source of truth;
this page should be updated to match.
← Back to Loan Repayment Calculator
Sources and References