Teaching Kids Programming: Videos on Data Structures and Algorithms
Geometric Progression of numbers are:

where q is neither 1 or 0. We want to compute the sum, aka 
Sum of Geometric Progression (Math Proof)
Let
where
,
and 
Multiple both sides with q (since q can’t be zero)

which is 
We can subtract both side from
aka


Therefore 
Python Algorithm to Compute the Sum of Geometric Progression
Here is the simple python function to compute the sum of a geometric progression.
def sum(a, q, n):
s = 0
for i in range(n):
s += a * (q ** i)
return s
We can also use math.pow(q, i) to compute the value of q to the power of i.
–EOF (The Ultimate Computing & Technology Blog) —
719 wordsLast Post: Teaching Kids Programming - Delete the Middle Node of a Linked List (Fast and Slow Pointer)
Next Post: Teaching Kids Programming - Words That Can Be Typed using a Single Keyboard Row (Hash Set)