Geometric Progression Sum
Given firstTerm, ratio, and terms, return the exact sum of the first terms values in the geometric progression that starts at firstTerm and multiplies by…
Given `firstTerm`, `ratio`, and `terms`, return the exact sum of the first `terms` values in the geometric progression that starts at `firstTerm` and multiplies by `ratio` each time. The three values are separate integer arguments. Return a signed integer.
- `-100 <= firstTerm <= 100` - `-5 <= ratio <= 5` - `1 <= terms <= 10` - All inputs are exact integers; booleans and non-integers are invalid. - The result fits in a signed 32-bit integer.
Example 1: input firstTerm = 3, ratio = 2, terms = 5; output 93. The terms are 3, 6, 12, 24, and 48.
Example 2: input firstTerm = -2, ratio = 3, terms = 4; output -80. The terms are -2, -6, -18, and -54.
Example 3: input firstTerm = 8, ratio = 0, terms = 3; output 8. After the first term, multiplying by zero makes each remaining term zero.
Category: Math & Numbers. Topic: math. Difficulty: Easy. Patterns: math.