#include <codecogs/finance/banking/nperiods.h>
using namespace Finance::Banking;
| enum | PaymentPoint Enumation of Payment point | |
| double | nPeriods (double rate,
double pmtValue,
double presentValue,
double futureValue,
Finance::Banking::PaymentPoint type=pp_EndOfPeriod) Return the number of periods for an investment.
Excel: NPER |
| doublenPeriods( | double | rate | |
| double | pmtValue | ||
| double | presentValue | ||
| double | futureValue | ||
| Finance::Banking::PaymentPoint | type = pp_EndOfPeriod | ) |

#include <iostream> #include <codecogs/finance/banking/nperiods.h> int main(void) { printf("nPeriods(0.01, -100, -1000, 10000, pp_StartOfPeriod) = %lf\n", Finance::Banking::nPeriods(0.01, -100, -1000, 10000, Finance::Banking::pp_StartOfPeriod)); printf("nPeriods(0.01, -100, -1000, 10000, pp_EndOfPeriod) = %lf\n", Finance::Banking::nPeriods(0.01, -100, -1000, 10000, Finance::Banking::pp_EndOfPeriod)); printf("nPeriods(0.01, -100, 1000, 0, pp_EndOfPeriod) = %lf\n", Finance::Banking::nPeriods(0.01, -100, 1000, 0, Finance::Banking::pp_EndOfPeriod)); return 1; }Output:
nPeriods(0.01, -100, -1000, 10000, pp_StartOfPeriod) = 59.673866 nPeriods(0.01, -100, -1000, 10000, pp_EndOfPeriod) = 60.082123 nPeriods(0.01, -100, 1000, 0, pp_EndOfPeriod) = 10.588644
| rate | The interest rate per period of the investment. |
| pmtValue | The payment made each period. This value must remain constant over the life of the annuity. |
| presentValue | The present value of the investment, or the lump-sum amount that a series of future payments is worth right now. |
| futureValue | The future value of the investment. |
| type | A value indicating whether the payment is made at the beginning or the end of each period. It is set to either: pp_EndOfPeriod or pp_StartOfPeriod. |