Drill

ProblemsTypeScript › finance

Simple interest earned

easyfinanceTypeScript

A saver is told the interest they would earn: principal held for years at a whole-percent annual rate, with no compounding.

simpleInterest(principal: int, ratePercent: int, years: int) → int

Solve it in the editor →

Where you start

function simpleInterest(principal: number, ratePercent: number, years: number): number {
  
}

Worked examples

CallResult
simpleInterest(1000, 5, 2)100
simpleInterest(10000, 10, 5)5000
simpleInterest(1234, 5, 3)185
simpleInterest(2500, 0, 10)0

Hint

Multiply all three, divide and round down.

Reference solution in TypeScript
function simpleInterest(principal: number, ratePercent: number, years: number): number {
  return Math.floor((principal * ratePercent * years) / 100);
}

The same problem in another language

More finance problems in TypeScript