Computer Science, asked by Anamikaas04, 5 months ago

print the sum of the following series
1-x+x²-x³+x⁴-x⁵.....x^n

❌DO NOT SPAM❌

[[∆correct answers get a follow and 10 thanks∆]]​

Answers

Answered by ayushbag03
3

Answer:

    Input: X = 2, N = 5

   Output: Sum = 31

   1 2 4 8 16

   Input: X = 1, N = 10

   Output: Sum = 10

   1 1 1 1 1 1 1 1 1 1

Answered by anindyaadhikari13
2

Question:-

Write a python program to print the sum of the series

1-x+x²-x³+x⁴.....xⁿ

Program:-

n=int(input("Enter the value of n: "))

x=float(input("Enter the value of x: "))

s=0

for i in range(0,n):

if (i%2==0):

s=s+x**i

else:

s=s-x**i

print("Sum of the series is: ",s)

Similar questions