Write the program 1 - 3 + 5 -7 + 9.....+limit in python using for loop.
Answers
Answered by
8
Answer:
k=(-1)
n=int(input())
sum=0
for i in range(1,n+1,2):
k=k*(-1)
print(k*i,end=" ")
sum+=(k*i)
print()
print("sum =",sum)
Explanation:
This is the python program for printing this sequence and sum
Similar questions