Arithmetic Progression Sum

Given firstTerm, difference, and terms, return the exact sum of the first terms values in the arithmetic progression that starts at firstTerm and changes by…

Given `firstTerm`, `difference`, and `terms`, return the exact sum of the first `terms` values in the arithmetic progression that starts at `firstTerm` and changes by `difference` each time. The three values are separate integer arguments. Return a signed integer.

- `-1000 <= firstTerm <= 1000` - `-100 <= difference <= 100` - `1 <= terms <= 100` - All inputs are exact integers; booleans and non-integers are invalid. - The result fits in a signed 32-bit integer.

Example 1: input firstTerm = 5, difference = 3, terms = 4; output 38. The terms are 5, 8, 11, and 14.

Example 2: input firstTerm = -2, difference = 4, terms = 5; output 30. The terms are -2, 2, 6, 10, and 14.

Example 3: input firstTerm = 7, difference = 0, terms = 3; output 21. Each of the three terms is 7.

Category: Math & Numbers. Topic: math. Difficulty: Easy. Patterns: math.