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 |
|||
05-17-2015, 09:15 AM
Post: #2
|
|||
|
|||
RE: Net Present Value
(03-28-2014 03:34 AM)Eddie W. Shore Wrote: HP Net Present Value Nice, Eddie! I hope you would like to develop also a function to calc IRR (Internal Rate of Return: see here) for the cash flow... thank you Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
03-05-2019, 06:10 AM
Post: #3
|
|||
|
|||
RE: Net Present Value
if returned an error, when enter NPV(3, [100, 5])
It cannot accept matrix 1x2 as an input. Can someone help? Thanks |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)