A Geometric series is a series with a constant ratio between successive terms. The first term of the series is denoted by a and the common ratio is denoted by r. The series looks like this:-
The task is to find the sum of such a series mod M.
Input: a = 1, r = 2, N = 10000, M = 10000 Output: 8751 Input: a = 1, r = 4, N = 10000, M = 100000 Output: 12501
- To find the sum of series we can easily take a as common and find the sum of and multiply it with a.
Steps to find the sum of above series.
Here, it can be resolved that:
If we denote,
This will work as our recursive case.
So, the Base cases are:
Sum(r, 0) = 1. Sum(r, 1) = 1 + r.
- Here, it can be resolved that:
Below is the implementation of the above approach.
Time complexity: O(log N)
- Geometric Progression
- Program to print GP (Geometric Progression)
- Number of GP (Geometric Progression) subsequences of size 3
- Program for N-th term of Geometric Progression series
- Removing a number from array to make it Geometric Progression
- Minimum number of operations to convert a given sequence into a Geometric Progression
- Check whether nodes of Binary Tree form Arithmetic, Geometric or Harmonic Progression
- Find geometric sum of the series using recursion
- Find larger of x^y and y^x
- Check if a larger number divisible by 36
- Find the larger exponential among two exponentials
- Smallest triangular number larger than p
- Number of Larger Elements on right side in a string
- Geometric Median
- Geometric mean (Two Methods)
- Find N Geometric Means between A and B
- Program for sum of geometric series
- Sum of Arithmetic Geometric Sequence
- Arithmetic Progression
- Harmonic Progression