I had already written about compound interest. I understood the formula well enough to explain it. Building the calculator still taught me things reading did not.
The first version was wrong
My first attempt handled a lump sum correctly and monthly contributions incorrectly. I was adding the contribution at the end of each year and then applying a year of growth to it, which quietly gave every contribution a free extra year of compounding.
The bug did not announce itself. The numbers looked plausible. I only found it because I checked a simple case by hand — ₹1,000 a month for one year at 0% should be exactly ₹12,000, and mine said ₹12,000 as well, which is why 0% was a bad test. At 10% the discrepancy showed up.
A test that passes for the wrong reason is worse than no test.
What the corrected version looks like
The future value of a series of regular contributions is its own formula, and adding it to the lump-sum term gives the full answer:
where i is the periodic rate and N is the number of periods. Deriving that second term — it is a geometric series — was the part I actually learned from.
Things I picked up that had nothing to do with finance
- Floating point arithmetic will not give you exact currency values, and you should not pretend it does.
- Naming variables after what they mean rather than what they are makes bugs visible.
- Plotting the output caught an error that reading the output did not. The curve had a kink in it that no reasonable growth curve should have.
Why I think building matters
When you read about an idea, you get to skip the parts you do not understand. When you implement it, the computer does not let you. Every ambiguity in your understanding becomes a decision you have to make explicitly.
That is the argument for the research notebook on this site. It is not a portfolio of impressive things. It is a record of ideas I was forced to understand properly.