Simple Interest

Given separate whole-integer arguments principal, rate and years, return the interest earned under simple interest as canonical ASCII decimal text with…

Given separate whole-integer arguments principal, rate and years, return the interest earned under simple interest as canonical ASCII decimal text with exactly two fractional digits. Principal is in whole abstract currency units; rate is a whole annual percentage. Return earned interest, excluding the original principal. Use exact integer cents; no rounding is needed.

0 <= principal <= 100000 0 <= rate <= 20 0 <= years <= 10 All inputs are exact integers; booleans and non-integers are invalid. No fractional principal, rate or years. Output has no symbol, grouping, whitespace or exponent. All integer intermediates fit signed int32 and JavaScript exact Number arithmetic.

Example 1: input principal = 1000, rate = 5, years = 2; output "100.00". 1000 × 5 gives 5000 cents per year; over 2 years, 10000 cents is 100.00 earned interest.

Example 2: input principal = 1, rate = 5, years = 1; output "0.05". 1 × 5 gives 5 cents per year; over 1 year, 5 cents is 0.05 earned interest.

Example 3: input principal = 1000, rate = 5, years = 0; output "0.00". 1000 × 5 gives 5000 cents per year; over 0 years, 0 cents is 0.00 earned interest.

Category: Math & Numbers. Topic: math. Difficulty: Easy. Patterns: math.