Skip to content

fix: correct compound interest loop so interest compounds each year#566

Open
Vineshnayak wants to merge 1 commit intowasmerio:mainfrom
Vineshnayak:fix/compound-interest-loop
Open

fix: correct compound interest loop so interest compounds each year#566
Vineshnayak wants to merge 1 commit intowasmerio:mainfrom
Vineshnayak:fix/compound-interest-loop

Conversation

@Vineshnayak
Copy link
Copy Markdown

PR Title

Fix compound interest calculation loop and output formatting

Summary

Fixed the compound interest logic so interest is applied correctly for each year. Also corrected a typo and improved output readability using round().

Description

The compound interest formula was previously placed outside the loop, causing interest to be applied only once regardless of the number of years entered. The formula has now been moved inside the loop to ensure proper yearly compounding.

Additionally:

  • Corrected the typo investin to investing
  • Added round() for cleaner and more readable output formatting

The changes are as follows:

  • Moved compound interest calculation inside the for loop
  • Fixed typo from investin to investing
  • Added round() to format output values neatly

Checks

in the repository

  • Made no changes that degrades the functioning of the repository
  • Gave each commit a better title (unlike updated README.md)

in the PR

  • Followed the format of the pull_request_template
  • Made the Pull Request in a small level (for the creator's wellfare)
  • Tested the changes you made

Thank You,

Vinesh nayak

The formula was placed outside the for loop, meaning interest was
only applied once regardless of years entered. Also fixed a typo
'investin' -> 'investing' and added round() for cleaner output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant