Given a real number a and a natural number n, compute the sum:
1 + a + a² + … + aⁿ
You are not allowed to use the formula for the sum of a geometric progression or the exponentiation operator.
The program’s running time must be proportional to n.
Two numbers: a and n.
Print the value of the sum.
| input | output |
|---|---|
| 2 | |
| 2 | 7 |
Sign in to submit your solution and save your progress.