Compound Interest
Programming Interview
Questions
Compound Interest
Write a function compound_interest(P, r, n, t) which calculates the total sum of an investment over a period of time.
Input:
- P: The principal amount (initial investment)
- r: The interest rate in decimal form (e.g. 0.05 is 5% investment rate)
- n: The number of times that interest is compounded per year, and
- t: The number of years the money is invested for
Output: The total sum of the investment after the compound interest has been accrued.
Your output must be rounded to a whole number.
Tests - Login / Sign up to submit your code!
Efficiency
Test Case 1
Test Case 2
Test Case 3
Test Case 4
Test Case 5
Test Case 6
Test Case 7
Test Case 8
Test Case 9
Test Case 10
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results