Please enter your email address or userHandle.
Given n, a and r as the number of terms, first term and common ratio respectively of an Geometric Progression Series. Find the sum of the series upto nth term.
Input: 3 3 2
Explanation: Series upto 3td term is
3 6 12, so sum will be 21.
Input: 3 1 2
Example: Series upto 3rd term is
1 2 4, so sum will be 7.
You don't need to read or print anything. Your task is to complete the function sum_of_gp() which takes n, a and r as input parameter and returns the sum of the series.
Expected Time Complexity: O(1)
Expected Space Complexity: O(1)
1 <= n, a, r <= 10
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.