You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
176 B
Python
8 lines
176 B
Python
5 years ago
|
def geometric_sum(n):
|
||
|
if n < 0:
|
||
|
return 0
|
||
|
else:
|
||
|
return 1 / (pow(2, n)) + geometric_sum(n - 1)
|
||
|
|
||
|
print(geometric_sum(7))
|
||
|
print(geometric_sum(4))
|