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

Cash-Flow Timelines and Net Present Value

A project whose future receipts must repay its initial cost.

2:35 clip47:40–50:15 in the full courseWatch on YouTube

Transcript

22 sentences · select one to jump there

Check your understanding

Why is the initial −1,000 not discounted?

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.

015-cash-flow-timelines-and-net-present-value.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 015 of 120
 * Cash-Flow Timelines and Net Present Value
 * Module 02: Financial Arithmetic, Time Value, and Returns
 *
 * Scenario: A project whose future receipts must repay its initial cost
 * Rule:     NPV = Σ CFₜ/(1+r)ᵗ
 *
 * Try it:   Why is the initial −1,000 not discounted?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/financial-arithmetic-time-value-and-returns/cashflow-npv/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson015() {
  const cashFlows = [-1000, 600, 600];
  const rate = 0.10;
  const contributions = cashFlows.map((cf, t) =>
    cf / (1 + rate) ** t);
  const result = contributions.reduce((a, x) => a + x, 0);
  return result;
}

export const checkedResult = 41.32231404958662;

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

Your output

Press Run to execute the code in your browser.

Expected output

41.32231404958662

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

Lesson notes

The rule

NPV = Σ CFₜ/(1+r)ᵗ