You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The nth term of a GP series is Tn = arn-1, where a = first term and r = common ratio = Tn/Tn-1) . The sum of infinite terms of a GP series S∞= a/(1-r) where 0< r<1. If a is the first term, r is the common ratio of a finite G.P.
Given an integer N, we need to find the geometric sum of the following series using recursion.
1 + 1/3 + 1/9 + 1/27 + … + 1/(3^n)
Input N = 5
Output: 1.49794
Input: N = 7
Output: 1.49977
Approach:
We will calculate the last term and call recursion on the remaining n-1 terms each time. The final sum returned is the result.