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:
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.
- 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 Maximum Level Sum in Binary Tree using Recursion
- Minimum number of operations to convert a given sequence into a Geometric Progression
- Sum of natural numbers using recursion
- Sum of digit of a number using recursion
- Sum of even elements of an Array using Recursion
- Count of subsets with sum equal to X using Recursion
- Find the value of ln(N!) 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
- Program to find all Factors of a Number using recursion
- Decimal to Binary using recursion and without using power operator
- Tail recursion to calculate sum of array elements.
- Print numbers 1 to N using Indirect recursion
- Remove duplicates from a sorted linked list using recursion
- Reverse a Doubly linked list using recursion
- Decimal to binary number using recursion
- Binary to Gray code using recursion
- Product of 2 Numbers using Recursion
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.