write a program in java to print the given series 3,6,12,24,48,....n terms
Answers
Answered by
2
Find the sum of series 3, -6, 12, -24 . . . upto N terms
Given an integer N. The task is to find the sum upto N terms of the given series:
3, -6, 12, -24, … upto N terms
Examples:
Input : N = 5
Output : Sum = 33
Input : N = 20
Output : Sum = -1048575
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
On observing the given series, it can be seen that the ratio of every term with their previous term is same which is -2. Hence the given series is a GP(Geometric Progression) series.
You can learn more about GP series here.
So,
S_{n} = \frac{a(1-r^{n})}{1-r} when r < 0.
In above GP series the first term i:e a = 3 and common ratio i:e r = (-2).
Therefore,
S_{n} = \frac{3(1-(-2)^{n})}{1-(-2)}.
Thus,
S_{n} = 1-(-2)^{n}.
PLEASE MAKE ME AS A BRAINLIST ANSWER
Similar questions