Wrong computation of functionality.

This commit is contained in:
Bhanu17Sharma02 2021-09-30 11:48:06 +05:30 committed by GitHub
parent 50a2b9376b
commit baa0296f78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -117,12 +117,10 @@ public final class FinanceLib {
*/
public static double npv(double r, double[] cfs) {
double npv = 0;
double r1 = r + 1;
double trate = r1;
for (double cf : cfs) {
npv += cf / trate;
trate *= r1;
}
for (int i=0;i<arr.length;i++)
{
npv+=cfs[i]/Math.pow(1+r,i);
}
return npv;
}