The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Net Present Value
03-28-2014, 03:34 AM
Post: #1
Net Present Value
HP Net Present Value
2014-03-28

Arguments:
NPV(periodical rate, list of cash flows)
or
NPV(periodical rate, [ cash flow, frequency ] )

Program:
EXPORT NPV(r, flows)
BEGIN
LOCAL t:=0, k, s;
r:=1+0.01*r;

CASE
// list
IF TYPE(flows)==6 THEN
s:=SIZE(flows);
FOR k FROM 1 TO s DO
t:=t+flows(k)/(r^(k-1));
END;
END;

// matrix
IF TYPE(flows)==4 THEN

LOCAL j, n;
s:=SIZE(flows);
k:=0;

FOR j FROM 1 TO s(1) DO
FOR n FROM 1 TO flows(j,2) DO
t:=flows(j,1)/(r^k)+t;
k:=k+1;
END;
END;

END;

DEFAULT
MSGBOX("NPV(rate, list) or NPV(rate, [flow, freq])");
KILL;
END;

RETURN t;
END;


--- Examples:

NPV(5, {-1000, 100, 250, 500, 750, 500}) returns 762.704203447

NPV(3, [[-1000, 1],[0, 5],[500, 5],[1500, 1]]) returns 2058.87973969
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Net Present Value - Eddie W. Shore - 03-28-2014 03:34 AM
RE: Net Present Value - salvomic - 05-17-2015, 09:15 AM
RE: Net Present Value - shuhei - 03-05-2019, 06:10 AM



User(s) browsing this thread: 2 Guest(s)