Answers for "how to make a series in python alternating between + and -"

0

how to make a series in python alternating between + and -

n = int(input("Integer n: "))
result = sum((-1)**(k+1) * k**2 for k in range(1, n + 1))
print(result)
Posted by: Guest on September-09-2021

Code answers related to "how to make a series in python alternating between + and -"

Python Answers by Framework

Browse Popular Code Answers by Language