6. Functions : Finance Library Functions : CTERM Function : Example—CTERM function:
 
Share this page                  
Example—CTERM function:
/*  Compute the number of years for a $5,000
**  investment to grow to $10,000 at 8% interest with
**  annual compounding.
*/
declare
     intRate = Float;
     futureVal = Float;
     presentVal = Float;
enddeclare
begin
     intRate = .08;          /* 8% per year */
     futureVal = 10000;
     presentVal = 5000;
     years = cterm(i = intRate, fv = futureVal, pv = presentVal);
end