Program to find the rate percentage from compound interest of consecutive years
Given two integers N1 and N2 which is the Compound Interest of two consecutive years. The task is to calculate the rate percentage.
Input: N1 = 660, N2 = 720
Output: 9.09091 %
Input: N1 = 100, N2 = 120
Output: 20 %
Approach: The rate percentage can be calculated with the formula ((N2 – N1) * 100) / N1 where N1 is the compound interest of some year and N2 is the compound interest for the next year.
Let us consider the 1st Example:
The difference between the Compound interest in the two consecutive years is because of the interest received on the previous year interest. Therefore,
–> N2 – N1 = N1 * (Rate / 100)
–> 720 – 660 = 660 * (Rate / 100)
–> (60 / 660) * 100 = Rate
–> Rate = (100 / 11) = 9.09% (Approx)
Below is the implementation of the above approach:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Be the First to upvote.
Please write to us at email@example.com to report any issue with the above content.