Method Deck / finance

Simple interest

Computes simple (non-compounding) interest and the total amount owed or earned on a principal over a term.

Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.

Try it

Inputs

Outputs

Steps

  1. Convert the annual rate to a decimal: r = annual_rate_percent / 100.
  2. interest = principal * r * years.
  3. total_amount = principal + interest.
  4. Round both interest and total_amount to 2 decimals (money to cents).

Constants

None.

Sources

Worked example and test vectors

NameInputsAnswer
worked example{"principal":1000,"annual_rate_percent":5,"years":3}$1,150.00
test vector: fractional year{"principal":2500,"annual_rate_percent":4.5,"years":2.5}$2,781.25

Published card