Skip to content

Instantly share code, notes, and snippets.

@kp666
Last active February 25, 2021 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kp666/8b2051add1a22139c4e99630d6f9c7a3 to your computer and use it in GitHub Desktop.
Save kp666/8b2051add1a22139c4e99630d6f9c7a3 to your computer and use it in GitHub Desktop.
// Compound interest
// Compound interest increases as a certain percentage
// of the principal each year. This gives us the formula
const compoundInterest = ({principal, ratePercentage, time}) => {
return principal * ((1 + ratePercentage/100) ** time);
};
const initialAmount =({finalAmount,ratePercentage, time })=> {
return finalAmount/((1 + ratePercentage/100) ** time);
}
compoundInterest({principal: 1, ratePercentage: 10, time: 7});
// initial buying power in a year
let principal = 1200000;
let fdInterestRate = 5;
let inflationRate = 7.8;
// the target buying power you want as interest from your savings. This is your income at the end of 10 years
let targetInterest = compoundInterest({principal: principal, ratePercentage: inflationRate, time: 10})
// the above income should come as interest from this final accured amount
let finalAccuredAmount = targetInterest * 100.0 / fdInterestRate;
// to get this final accured amount you need to have atleast this amount in bank at the moment.
initialAmount({finalAmount: finalAccuredAmount, ratePercentage: fdInterestRate, time: 10})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment