finding sum of finite geometric series code example Example: formula for finite geometric series a(1-rⁿ)/(1-r).