Calculator formulas
Compound Interest Calculator Formula: Contributions and Timing Tests
Use one explicit rate convention, contribution timing rule and zero-rate branch, then verify the calculator with twelve deterministic cases before publishing it.
Direct answer
Use A = P(1 + r/n)^(nt) for the starting balance. When equal contributions share the compounding period, add C((1 + i)^m - 1)/i for end-of-period deposits, where i is the periodic rate and m is the number of periods. Multiply only the contribution term by (1 + i) for beginning-of-period deposits. Add a separate zero-rate branch, publish the timing assumptions, and reject unsupported frequency combinations rather than guessing.
Definition
A compound interest calculator projects a starting balance and any repeated contributions under a declared rate, compounding frequency, contribution frequency and payment timing. It is a scenario model, not a promised return or product recommendation.
Key findings
Verified 23 November 2026
- For a lump sum, use A = P times (1 + r divided by n) raised to n times t, with the rate convention and period count shown beside the result.
- For equal end-of-period contributions that match the compounding period, add C times (((1 + i) raised to m) minus 1) divided by i. Beginning-of-period contributions multiply that contribution term by (1 + i).
- At a zero periodic rate, use P + C times m. Do not evaluate the ordinary-annuity fraction at i = 0.
- Do not quietly convert an effective annual rate as though it were nominal, or combine monthly contributions with another compounding frequency without a declared conversion policy.
What does a compound interest calculator calculate?
A compound interest calculator projects how a starting balance changes when each period's return becomes part of the balance used by the next period. Repeated contributions add a second cash-flow stream, so their timing matters as much as the headline rate.
Investor.gov asks for an initial investment, monthly contribution, time, estimated annual rate and compounding frequency. Those labels are a useful minimum, but a reproducible implementation must also state whether the annual rate is nominal or effective, whether contributions arrive at the beginning or end of a period, and what the model excludes.
This article uses a constant nominal annual rate, matching contribution and compounding periods, and no tax, fees, inflation or withdrawals unless a fixture says otherwise. It is a calculation contract, not financial advice or a forecast.
Sources: Investor.gov compound interest calculator; Investor.gov explanation of compound interest
What formula should the calculator use?
For a starting principal P, nominal annual rate r, n compounding periods per year and t years, the lump-sum future value is A principal = P times (1 + r divided by n) raised to n times t.
When contributions C arrive at the end of every compounding period, let i = r divided by n and m = n times t. The contribution value is A contributions = C times (((1 + i) raised to m) minus 1) divided by i. Add the two terms for the displayed balance.
When contributions arrive at the beginning of each period, multiply only the contribution term by (1 + i). At i = 0, use P + C times m. This branch avoids division by zero and makes the no-growth result auditable.
COMPOUND-INTEREST-FORMULA-FIXTURES
| Input | Contract | Failure if omitted |
|---|---|---|
| Annual rate | Label nominal or effective and accept a decimal internally | A displayed 5% can mean different periodic rates |
| Compounding | Declare periods per year | Monthly and annual results become indistinguishable |
| Contribution timing | Beginning or end of period | Every contribution may earn one period too much or too little |
| Duration | Use an integer period count or a declared stub-period rule | Partial periods are silently rounded |
| Zero rate | Use P + C times m | The ordinary-annuity fraction divides by zero |
| Rounding | Keep full precision internally, round only the displayed currency | Period-by-period rounding can drift from the contract |
How does contribution timing change the result?
An end-of-period contribution earns interest from the next period onward. A beginning-of-period contribution earns one additional period, so its future-value term is larger by the factor (1 + i). The starting principal does not receive that extra multiplier because it is already present at time zero.
A calculator should name the timing beside the input or result. Terms such as monthly contribution are incomplete on their own because two calculators can accept the same numbers and legitimately return different balances when one assumes the first contribution today and the other assumes it arrives after one month.
| Cash flow | Timing | Treatment |
|---|---|---|
| Starting principal | Time zero | Compound for every modeled period |
| Regular deposit | End of period | Ordinary-annuity contribution term |
| Regular deposit | Beginning of period | Ordinary-annuity term times (1 + i) |
| Withdrawal | Declared period boundary | Negative contribution under the same timing rule |
| Irregular cash flow | Dated event | Use a schedule, not the equal-contribution shortcut |
Worked example: monthly contributions
Assume a fictional starting balance of $5,000, a nominal annual rate of 6%, monthly compounding, $200 contributed at the end of each month and 24 months. The periodic rate is 0.06 divided by 12, or 0.005, and the period count is 24.
The starting balance grows to $5,000 times 1.005 raised to 24. The contribution stream adds $200 times ((1.005 raised to 24 minus 1) divided by 0.005). The combined unrounded result is about $10,722.19. If the same $200 arrives at the beginning of each month, the contribution term receives one additional 1.005 multiplier and the result is about $10,747.62.
The $25.43 difference is not a rounding error. It is the value of one extra month of assumed growth on each contribution. The calculator should expose that assumption rather than selecting it silently.
What did the twelve deterministic tests cover?
The executed suite covers lump-sum growth, end and beginning contributions, zero rate, zero duration, a withdrawal, fractional currency display, invalid frequency, negative duration, non-finite input and an unsupported mismatch between contribution and compounding periods.
Each valid fixture compares the unrounded engine result with a fixed expected value within a declared tolerance. Display rounding is tested separately so a two-decimal result cannot hide a formula error.
| Case | Scenario | Expected decision |
|---|---|---|
| CI01 | $1,000 at 0% for one year | $1,000.00 |
| CI02 | $100 monthly for 12 months at 0%, end timing | $1,200.00 |
| CI03 | $1,000 at 5%, annual compounding for 10 years | $1,628.89 displayed |
| CI04 | $5,000 plus $200 monthly at 6% for 24 months | $10,722.19 displayed |
| CI05 | Same values with beginning timing | $10,747.62 displayed |
| CI06 | Compounding frequency of zero | Invalid input |
| CI07 | Monthly contribution with unsupported quarterly shortcut | Unsupported combination |
| CI08 | Zero duration | Return the current principal |
| CI09 | Negative duration | Invalid input |
| CI10 | Non-finite principal | Invalid input |
| CI11 | $100 monthly withdrawal at 0% for 12 months | -$1,200 contribution effect |
| CI12 | Fractional currency before display | Keep full precision, then round once |
Which edge cases need explicit result states?
Zero duration returns the current principal before any recurring contribution is due. A negative duration, non-finite amount or zero compounding frequency is invalid. If a withdrawal schedule drives the balance below a business rule's allowed floor, return that declared state instead of formatting an unexplained negative currency value.
A rate below zero may be mathematically supported, but the interface must say so and enforce a lower bound that keeps every periodic factor meaningful. A real product may also need fees, taxes, rate changes, contribution changes or dated cash flows. Those require a schedule model rather than hidden additions to this shortcut.
How should the result be presented accessibly?
Show the balance, total contributions, modeled growth and assumptions as text. A chart can reinforce the result, but it should not be the only place that distinguishes principal from contributions and growth.
Keep format and timing instructions beside their controls, identify input errors in text and preserve entered values when a correction is required. W3C guidance recommends clear labels, instructions and validation that lets a person identify and fix an error.
Sources: W3C form instructions; W3C form validation
What are the limitations of this formula?
This fixed-rate formula does not predict market returns, guarantee a savings rate or choose a financial product. It excludes tax, fees, inflation, irregular deposits, changing rates and day-count conventions unless the implementation adds and documents them.
If contribution and compounding periods differ, use a declared rate-conversion and cash-flow schedule. Do not divide an effective annual rate by twelve or force quarterly compounding into a monthly-annuity formula without proving the equivalence.
Verification and corrections
The sources and twelve deterministic fixtures were checked on 23 November 2026. Reverify the article after any formula, rate-label, timing, rounding, fee, tax, inflation or result-delivery change.
To request a correction, identify the exact statement, the proposed replacement and a primary source or reproducible fixture through the corrections page.
Method and evidence
Evidence type: Versioned formula contract, timing decision table, worked example and twelve executed deterministic fixtures
- Separated the starting principal from repeated contributions and declared whether contributions arrive at the beginning or end of each period.
- Used a nominal annual rate divided by the matching compounding frequency only when contribution periods and compounding periods align.
- Added explicit zero-rate, zero-duration, invalid-input and unsupported-frequency states instead of relying on division by zero or silent conversion.
- Executed twelve deterministic fixtures and rechecked current Investor.gov calculator inputs and W3C form guidance on 23 November 2026.
Topic score: 4.66 / 5. Business fit 4.6, verified demand 4.9, distinct intent 4.7, original evidence 4.7, citation usefulness 4.5, feasibility 4.6.
Primary sources
- Investor.gov compound interest calculator ↗Current public input model for principal, contributions, time, rate and compounding frequency, checked 23 November 2026.
- Investor.gov savings goal calculator ↗Current public solve-for-contribution context, checked 23 November 2026.
- W3C form instructions ↗Accessible labels and input instructions, checked 23 November 2026.
- W3C form validation ↗Error identification and correction guidance, checked 23 November 2026.
Limitations
- The worked values are fictional and are not a forecast, rate quote or recommendation.
- The formula assumes a constant nominal rate and matching contribution and compounding periods.
- Tax, fees, inflation, irregular cash flows and changing rates require additional documented rules.
- Automated fixture coverage does not replace financial, legal, accessibility or product review for a regulated implementation.
Verification and corrections
Investor.gov compound-interest and savings-goal calculators, W3C form instructions and twelve deterministic fixtures verified 23 November 2026.
Recommended retest: Recheck after any rate-label, compounding, contribution-timing, fee, tax, inflation, rounding or result-delivery change.
Found an error or a changed standard? Use the correction process and include the page URL and primary evidence.
Next step
Apply the evidence to your next release
Use the published method, keep a dated test record and revisit the result after the calculator or its operating rules change.
Open the testing protocol