math Common summations in computer science Sum of a geometric series: r^0 + r^1 + r^2 + ...


Example

The sum of the geometric series

r0 + r1 + r2 + ... + rn-1

In the case where r ≠ 1, simplifies to (rn - 1) / (r - 1). If r < 1, this sum is bounded from above by 1 / (1 - r).

If r = 1, this sum is rn.