Skip to content

Instantly share code, notes, and snippets.

@yasalmasri
Created March 30, 2021 15:06
Show Gist options
  • Save yasalmasri/b9586d337b3b6ef738ab3f9f7e5fb1f9 to your computer and use it in GitHub Desktop.
Save yasalmasri/b9586d337b3b6ef738ab3f9f7e5fb1f9 to your computer and use it in GitHub Desktop.

Need to calculate interest for monthly and annually investments:

  • Every month I create an investment with an $XXX amount.
  • All investments are for 1 year with XXX% percentage.
  • Each investment will be recreated with the amount and the gained intereset for example: Year 1: I invest $1000 MXN Year 2: I earn $1100 MXN, I recreate the investment with the amount $1100 MXN and so on for the next years
  • All the monthly investments will be treated the same way.
  • Need to calculate all the interest after XXX date and consider that the last year will only save the monthly amount not investing it.

Example:

Start Date: 1/1/2021 Years: 10 Monthly Amount: $1000 MXN Annually Interest Percentage: 10% So I invest $1000 with 10% interest so next year will give $1100 and will reinvest the amount with interest (compound interest) I need to repeat this transaction everymonth for 10 years, so everymonth I will invest $1000 for 1 year with 10% interest and reinvest the amount with the interest next year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment