1---
2version: 0.1.0
3precision: 2
4form_title: Compound Interest Calculator
5form_description: See how compound interest grows your money. Enter initial amount, interest rate, years and monthly contributions to see final value and interest earned.
6form_inputs: Initial amount|principal{€}, Interest rate|rate{%}, Years|years{years}, Monthly deposit|deposit{€}
7form_outputs: Final amount|final, Principal invested|invested, Interest earned|interest, Annual growth|annual_growth
8---
9# draftply – Compound Interest Calculator
10# The power of compound interest over time.
11
12# ── Investment parameters ────────────────────────────────
13principal = 10000 € # initial investment
14rate = 5 % # annual interest rate
15years = 20 years # investment period
16deposit = 200 € # monthly additional deposit
17
18# ── Calculations ──────────────────────────────────────
19# Monthly interest rate
20monthly_rate = rate / 12
21months = years * 12
22
23# Future value of initial principal
24fv_principal = principal * (1 + monthly_rate)^months
25
26# Future value of monthly deposits (annuity)
27annuity_factor = ((1 + monthly_rate)^months - 1) / monthly_rate
28fv_deposits = deposit * annuity_factor
29
30# Total final amount
31final = fv_principal + fv_deposits
32
33# Total invested (principal + all deposits)
34invested = principal + deposit * months
35
36# Interest earned
37interest = final - invested
38
39# Effective annual growth rate (CAGR)
40cagr = ((final / principal)^(1/years) - 1) * 100
41
42# What if no additional deposits?
43final_no_deposits = principal * (1 + monthly_rate)^months
44
45# What if deposits but no principal?
46final_deposits_only = deposit * annuity_factor
47
48# Rule of 72: years to double at this rate
49years_to_double = 72 / (rate * 100)
50
51# ── Results ─────────────────────────────────────────────
52"Initial investment": principal
53"Monthly deposit": deposit
54"Interest rate (%)": rate * 100
55"Investment period": years
56
57"Final amount": final
58"Total invested": invested
59"Interest earned": interest
60
61"CAGR (annual growth)": cagr
62"Years to double at this rate": years_to_double
63
64"Without deposits": final_no_deposits
65"Deposits only": final_deposits_only
66
67# Growth visualization
68growth(year) = (principal * (1 + monthly_rate)^(year * 12)) + (deposit * (((1 + monthly_rate)^(year * 12) - 1) / monthly_rate))
69plot(growth(x), 0..years, "Investment growth", "Years", "€", "Value over time")
70