Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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)
Source by www.reddit.com #
 
PREVIOUS NEXT
Tagged: #series #python #alternating
ADD COMMENT
Topic
Name
2+3 =