Write a Python function to calculate the geometric sum of n-1.


Topic: Write a Python function to calculate the geometric sum of n-1.

Solution

def geometric_sum(n):
  if n < 0:
    return 0
  else:
    return 1 / (pow(2, n)) + geometric_sum(n - 1)



List all Python Programs