NPER(rate,pmt,pv,[fv],[type]) solves for the number of equal payment periods at a fixed periodic rate. Future value defaults to zero; type zero pays at period end and type one at the beginning. The result may be fractional.
Try it
=NPER(0,-250,1000) returns 4. At zero interest, four outflows of 250 repay the positive principal. A nonzero rate can require more periods for the same payment.
Quirks
Cash-flow signs matter: a positive principal and negative payments describe repayment. Exactly zero rate is a separate branch. A tiny nonzero rate that makes the stored 1+rate round to one reaches a logarithmic denominator of zero, giving #DIV/0! in the recorded route; it must not be replaced by a small-rate approximation.
How to implement
Use R(op) for 64-bit-significand rounding followed by a binary64 store. At zero rate, return R(-R(fv+pv)/pmt) and reject a zero payment. Otherwise set tf=1 for type zero or R(1+r) for type one, then a=R(tf*pmt), num=R(a-R(fv*r)), den=R(a+R(pv*r)), and ratio=R(num/den). Reject a nonpositive or nonfinite ratio and a nonpositive stored base=R(1+r). Return R(LN(ratio)/LN(base)) using the measured worksheet logarithm; a zero denominator log gives #DIV/0!.
The zero-rate example computes -1000/-250=4. This recipe preserves the recorded stores; it does not round the period count to an integer or establish all workbook input routes.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
4 nper_fn "NPER" (3, 5) [V"rate", V"pmt", V"pv", V"fv", V"type"] |s, a, sv| {
let t = timing(s, a, 4)?;
tv_out(s, tv::nper(num(s, a, 0)?, num(s, a, 1)?, num(s, a, 2)?, opt(s, a, 3, 0.0)?, t))
}
No implementation has been published with a Handbook test suite for this function.
Version differences
The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.
Excel 16.0 build
Platform and CPU
Captured inputs
20131
Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics
1,291
20430
Windows, 64-bit, CPU not recorded
1,210
The record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.
Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics
1,291 captured inputs are indexed for this environment. Capture dates: 2026-07-11 to 2026-07-11. This is a reading count, not a comparison with another build.
Excel 16.0 build 20430
Windows, 64-bit, CPU not recorded
1,210 captured inputs are indexed for this environment. Capture dates: 2026-09-29 to 2026-09-29. This is a reading count, not a comparison with another build.
Alternatives
PMT solves the payment; RATE solves the rate; PDURATION describes growth without intervening payments.