Write a program to find and display the sum of the given series:s = 1 –a + a2–a3+ .......... + a10
Answers
Answered by
0
I'll be using python here,
It goes like:
___________________________________
a=input("Enter the number list: ")
sum= 0
for i in range(0, len(a)):
if i%2==0:
sum+=i
else:
sum-=1
print("The sum of the series will be", sum)
___________________________________
What I did here?
I accepted 1, a1, a2.. a10 in form of a list in the program and then added it to 0 with a variable sum if the number is at even position (for even numbers i%2 will be 0) and subtracted those with odd positions.
Similar questions