Given Mth and Nth term of a Geometric progression. Find its Pth term.
Input: m = 10, n = 5, mth = 2560, nth = 80, p = 30
Output: pth = 81920
Input: m = 8, n = 2, mth = 1250, nth = 960, p = 15
Let a is the first term and r is the common ratio of the given Geometric Progression. Therefore
mth term = a * pow ( r, (m-1) ) ....... (i) and nth term = a * pow ( r, (n-1) ) ....... (ii)
For convenience, it is assumed that m > n
From these 2 equation,
Since we have given values m, n, mth term, and nth term, therefore
r = pow(A/B, 1.0/(m-n))
Now put the value of r in any of above two equation and calculate the value of a.
a = mth term / pow ( r, (m-1) ) or
a = nth term / pow ( r, (n-1) )
After finding the value of a and r, use the formula of Pth terms of a GP.
pth term of GP = a * pow ( r, (p-1.0) );
Below is the implementation of the above approach:
- Find n terms of Fibonacci type series with given first two terms
- Find the Nth term of the series where each term f[i] = f[i - 1] - f[i - 2]
- Find the sum of all the terms in the n-th row of the given series
- Find the sum of first N terms of the series 2×3 + 4×4 + 6×5 + 8×6 + ...
- Find the sum of first N terms of the series 2*3*5, 3*5*7, 4*7*9, ...
- Find the sum of n terms of the series 1,8,27,64 ....
- Find sum of the series ?3 + ?12 +......... upto N terms
- Find Sum of Series 1^2 - 2^2 + 3^2 - 4^2 ..... upto n terms
- Find the sum of series 3, -6, 12, -24 . . . upto N terms
- Find the sum of series 0.X + 0.XX + 0.XXX +... upto k terms
- Program to find the sum of the series 23+ 45+ 75+..... upto N terms
- Find sum of the series 1+22+333+4444+...... upto n terms
- Find the sum of the series 1+11+111+1111+..... upto n terms
- Number of quadruples where the first three terms are in AP and last three terms are in GP
- Find n-th term in series 1 2 2 3 3 3 4 4 4 4....
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.