Module 2 · Financial Arithmetic, Time Value, and Returns Lesson 12 of 120

Compound Interest

When a savings balance earns on previous interest.

2:30 clip40:04–42:34 in the full courseWatch on YouTube

Transcript

21 sentences · select one to jump there

Check your understanding

Why is year-two interest 52.50 rather than 50?

Choose one answer

Code lab

Run it yourself

The lesson source in 7 languages. Edit it, run TypeScript and Python right here, and compare with the expected output.

012-compound-interest.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 012 of 120
 * Compound Interest
 * Module 02: Financial Arithmetic, Time Value, and Returns
 *
 * Scenario: When a savings balance earns on previous interest
 * Rule:     FV = P(1+r)ⁿ
 *
 * Try it:   Why is year-two interest 52.50 rather than 50?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/financial-arithmetic-time-value-and-returns/compound-interest/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson012() {
  const principal = 1000, rate = 0.05;
  const balances = Array.from({length: 4}, (_, t) =>
    principal * (1 + rate) ** t);
  const result = balances;
  return result;
}

export const checkedResult = [1000,1050,1102.5,1157.6250000000002];

// Run this file directly: npx tsx lessons/02-financial-arithmetic-time-value-and-returns/012-compound-interest.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson012(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

[
  1000,
  1050,
  1102.5,
  1157.6250000000002
]

Prefer your own machine? Every file is in the course repository · open it in Codespaces.

Lesson notes

The rule

FV = P(1+r)ⁿ