Find the sum of series M/1 + (M+P)/2 + (M+2*P)/4 + (M+3*P)/8……up to infinite where M and P are positive integers.
Input : M = 0, P = 3; Output : 6 Input : M = 2, P = 9; Output : 22
S = M/1 + (M + P)/2 + (M + 2*P)/4 + (M + 3*P) / 8……up to infinite
so the solution of this series will be like this
we are going to divide this series into two parts-
S = (M/1 + M/2 + M/4 + M/8……up to infinite) + ( p/2 + (2*p)/4 + (3*p)/8 + ….up to infinite)
let us consider it
S = A + B ……..eq(1)
A = M/1 + M/2 + M/4 + M/8……up to infinite
A = M*(1 + 1/2 + 1/4 + 1/8….up to infinite)
which is G.P of infinite terms with r = 1/2;
According to the formula of G.P sum of infinite terms for r < 1 and
a is first term and r is common ratio so now,
A = M * ( 1 / (1 – 1/2) )
A = 2 * M ;
Now for B –
B = ( p/2 + (2*p)/4 + (3*p)/8 + ….up to infinite)
B = P/2 * ( 1 + 2*(1/2) + 3*(1/4) + ……up to infinite)
it is sum of AGP of infinite terms with a = 1, r = 1/2 and d = 1;
According to the formula where a is first term,
r is common ratio and d is common difference so now,
B = P/2 * ( 1 / (1-1/2) + (1*1/2) / (1-1/2)^2 )
B = P/2 * 4
B = 2*P ;
put value of A and B in eq(1)
S = 2(M + P)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find the sum of infinite series 1^2.x^0 + 2^2.x^1 + 3^2.x^2 + 4^2.x^3 +.......
- Measure one litre using two vessels and infinite water supply
- Find minimum moves to reach target on an infinite line
- Minimum steps needed to cover a sequence of points on an infinite grid
- Find if the given number is present in the infinite sequence or not
- Find the count of unvisited indices in an infinite array
- Minimum moves to reach target on a infinite line | Set 2
- Sum of sum-series of first N Natural numbers
- Sum of series formed by difference between product and sum of N natural numbers
- Program to find sum of series 1 + 1/2 + 1/3 + 1/4 + .. + 1/n
- Efficient Program to Compute Sum of Series 1/1! + 1/2! + 1/3! + 1/4! + .. + 1/n!
- Find the sum of all the terms in the n-th row of the given series
- Program for sum of geometric series
- Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Java Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Program for sum of arithmetic series
- Series with largest GCD and sum equals to n
- Program to find Sum of a Series a^1/1! + a^2/2! + a^3/3! + a^4/4! +…….+ a^n/n!
- Sum of the series 1 + (1+3) + (1+3+5) + (1+3+5+7) + …… + (1+3+5+7+…+(2n-1))
- Sum of the Series 1/(1*2) + 1/(2*3) + 1/(3*4) + 1/(4*5) + . . . . .
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.
Improved By : Mithun Kumar