CFLib.org – Common Function Library Project

CompoundInterest(r, p, t)

Last updated April 23, 2002

Version: 1 | Requires: ColdFusion 5 | Library: FinancialLib

 
Rated 1 time(s). Average Rating: 2.0

Description:
Calculate the compound interest after n years.

Return Values:
Returns a numeric value.

Example:

view plain print about
<cfoutput>
Future value:
<P>
100 dollars for 1 year at 10%: #DollarFormat(compoundInterest(0.1, 100, 1))#<br>
100 dollars for 2 years at 10%: #DollarFormat(compoundInterest(0.1, 100, 2))#<br>
100 dollars for 3 years at 10%: #DollarFormat(compoundInterest(0.1, 100, 3))#
</cfoutput>

Parameters:

Name Description Required
r Interest rate (3% = 0.03). Yes
p Principal Yes
t Duration of the loan in years. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Calculate the compound interest after n years.
 * 
 * @param r      Interest rate (3% = 0.03). 
 * @param p      Principal 
 * @param t      Duration of the loan in years. 
 * @return Returns a numeric value. 
 * @author Stephan Scheele (stephan@stephan-t-scheele.de) 
 * @version 1, April 23, 2002 
 */

function compoundInterest(r, p, t){
  return (p* (1 + r)^t);
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson