Answer to Question #326317 in Python for Venkatesh

Question #326317

write a program to find the sum S of the series where S = x - x^3 + x^5 + ..... upto N items.

1
Expert's answer
2022-04-09T17:52:47-0400
x = int(input('x = '))
n = int(input('n = '))
s = 0
power = 1
sign = 1
for i in range(n):
	s += sign * (x**power)
	power += 2
	sign *= -1
print(f"sum = {s}")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS