{
  "schemaVersion": 1,
  "slug": "rule-of-72-calculator",
  "category": "finance",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "ffedda3775b271c592b7a8af6c03b99426aa35413a9e0b599a37c41c5b3fcbee",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/rule-of-72-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "t72 = 72 ÷ i; t = ln 2 ÷ ln(1 + i ÷ 100); FV = P × 2^(Y ÷ t)",
    "vars": [
      [
        "i",
        "Annual interest rate (%)"
      ],
      [
        "t72",
        "72-rule estimate (years)"
      ],
      [
        "t",
        "Exact doubling time (years)"
      ],
      [
        "P",
        "Principal"
      ],
      [
        "Y",
        "Investment years"
      ]
    ],
    "note": "Annual compounding; doublings = Y ÷ t; t72 is approximate and the gap to t is reported."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const r=rate/100;\nconst approx = 72/rate;\nconst exact = r>0 ? Math.log(2)/Math.log(1+r) : 0;\nconst d = exact>0 ? years/exact : 0;\nreturn { yearsToDouble: approx, exactDoublingTime: exact, difference: approx-exact, doublings: d, futureValue: principal*Math.pow(2,d) };",
    "inputs": [
      {
        "name": "rate",
        "type": "number",
        "default": 7,
        "min": 0.5,
        "max": 25,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "principal",
        "type": "number",
        "default": 10000,
        "min": 0,
        "max": 100000000,
        "step": 500
      },
      {
        "name": "years",
        "type": "number",
        "default": 20,
        "min": 1,
        "max": 60,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "yearsToDouble",
        "precision": 2,
        "unit": "years"
      },
      {
        "name": "exactDoublingTime",
        "precision": 2,
        "unit": "years"
      },
      {
        "name": "difference",
        "precision": 2,
        "unit": "years"
      },
      {
        "name": "doublings",
        "precision": 2,
        "unit": ""
      },
      {
        "name": "futureValue",
        "precision": 0,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
