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
In the above-mentioned problem, we are asked to use recursion. We will calculate the last term and call recursion on the remaining n-1 terms each time. The final sum returned is the result.
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Sum of N-terms of geometric progression for larger values of N | Set 2 (Using recursion)
- Sum of the series 1^1 + 2^2 + 3^3 + ..... + n^n using recursion
- Find the value of ln(N!) using Recursion
- Program to find all Factors of a Number using recursion
- Find Maximum Level Sum in Binary Tree using Recursion
- Find the node with maximum value in a Binary Search Tree using recursion
- Find maximum and minimum element in binary tree without using recursion or stack or queue
- Find the Nth term of the series 2, 15, 41, 80, 132...
- Recursive program to find the Sum of the series 1 - 1/2 + 1/3 - 1/4 ... 1/N
- Find the kth element in the series generated by the given N ranges
- Minimum number of operations to convert a given sequence into a Geometric Progression
- Tail Recursion
- Practice Questions for Recursion | Set 6
- Practice Questions for Recursion | Set 5
- Practice Questions for Recursion | Set 4
- Practice Questions for Recursion | Set 7
- Different Types of Recursion in Golang
- Sum of even elements of an Array using Recursion
- Practice Questions for Recursion | Set 2
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.