Sum of the series
This Program name is Sum of the series. Write a Python program to Sum of the series, it has two test cases
The below link contains Sum of the series question, explanation and test cases
https://drive.google.com/file/d/15oYX0I0vkskebiNz7Wg80SdkZ-MzHTrg/view?usp=sharing
We need exact output when the code was run
X = int(input('Enter integer here: '))
N = int(input('Enter integer here: '))
M = 1 + 2*(N-1)
list1 = []
i = 1
j = 0
k = 0
while i <= M:
list1.append(X**i)
i = i + 2
for s in list1:
if (list1.index(s))%2 == 0:
j = j + s
else:
k = k - s
print(j+k)
Enter integer here: 2
Enter integer here: 5
410
Enter integer here: 3
Enter integer here: 2
-24
Comments
Leave a comment