Write a code to find out the sum of the sequence 2 -4 6 -8 10 -12.... while the last value will be determined from input. Use a loop to solve the problem.
1
Expert's answer
2021-08-26T18:52:36-0400
n = int(input())
m = 1
total = 0
while True:
total += 2 * m * (-1) ** (m - 1)
if 2 * m * (-1) ** (m - 1) == n:
break
m += 1
print(total)
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment