Skip to content
RED SAGSkills
easy15 ptsfintechmath

Fixed Deposit Maturity Amount

A savings app shows customers what a fixed deposit will be worth at maturity. Interest is compounded timesPerYear times a year at a nominal annual rate of annualRatePercent.

The maturity amount is principal * (1 + annualRatePercent / 100 / timesPerYear) ^ (timesPerYear * years).

Return it rounded to 2 decimal places using Math.round(amount * 100) / 100.

Example 1

Input: principal = 10000, annualRatePercent = 5, years = 1, timesPerYear = 1
Output: 10500
Explanation: One yearly compounding at 5%.

Example 2

Input: principal = 10000, annualRatePercent = 12, years = 1, timesPerYear = 12
Output: 11268.25
Explanation: Monthly compounding: 10000 x 1.01^12.

Constraints

  • 1 <= principal <= 10^8
  • 0 <= annualRatePercent <= 30
  • 1 <= years <= 40 (integer)
  • timesPerYear is one of 1, 2, 4, 12, 365
Hint 1

Math.pow(base, exponent) or base ** exponent does the compounding in one step.

Good practice for: Backend Developer, Full Stack Developer, Blockchain Developer, Data Engineer, Automation Test Engineer, Mobile App Developer, Data Scientist

Run checks your code on 3 sample tests. Submit runs all 8 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.