Created
May 12, 2010 15:20
-
-
Save goshki/398707 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Calculates a compound interest (procent składany) for a given period of time | |
* with given annual interest rate, number of capitalizations and saving period. | |
* | |
* @param amount | |
* initial investment | |
* | |
* @param interestRate | |
* nominal annual interest rate (in decimal, so if interest rate is 5%, | |
* we give 0.05) | |
* | |
* @param capitalizations | |
* number of capitalizations per year | |
* | |
* @param period | |
* saving period (in years, as decimal if shorter period needed) | |
* | |
* @return calculated compound interest | |
*/ | |
function compoundInterest( amount, interestRate, capitalizations, period ) { | |
return amount * Math.pow( ( 1 + ( interestRate / capitalizations ) ), | |
capitalizations * period ); | |
} | |
alert( compoundInterest( 10000.0, 0.04, 365, 0.4 ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment