write a program to find the sum S of the series where S = x-x^3+x^5+..... upto N terms.
def getSum(x, membership):
i = 1
sumSeries = 0
for member in range(membership):
if member % 2 > 0:
sumSeries += -x**i
i += 2
else:
sumSeries += x**i
i += 2
return sumSeries
x = int(input())
membership = int(input())
print(getSum(x, membership))
Comments
Leave a comment