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)
- Sum of elements of a Geometric Progression (GP) in a given range
- Find geometric sum of the series using recursion
- Removing a number from array to make it Geometric Progression
- Number of GP (Geometric Progression) subsequences of size 3
- Program for N-th term of Geometric Progression series
- Program to print GP (Geometric Progression)
- Minimum number of operations to convert a given sequence into a Geometric Progression
- Geometric Progression
- Check whether nodes of Binary Tree form Arithmetic, Geometric or Harmonic Progression
- Minimum sum of the elements of an array after subtracting smaller elements from larger
- Program for sum of geometric series
- Sum of Arithmetic Geometric Sequence
- Find Harmonic mean using Arithmetic mean and Geometric mean
- Check if a larger number divisible by 36
- Find larger of x^y and y^x
- Smallest triangular number larger than p
- Number of Larger Elements on right side in a string
- Larger of a^b or b^a (a raised to power b or b raised to power a)
- Find the larger exponential among two exponentials
- Harmonic progression Sum
Improved By : sanjoy_62