Monday 8 February 2021

Practical 3: Write a program in Python to input the value of x and n and print the sum of the following series 1+x+x^2+x^3+ ----------------x^n

 









#Practical No. - 3 : WAP in Python to input the value of x and n and
#print the sum of the following series
# 1 + x + x^2 + x^3 + ............. + x^n

x=int(input("Enter the value of x: "))
n=int(input("Enter the value of n: "))
sum=0
for i in range(0,n+1):
    sum=sum+x**i


print("Sum of series=",sum)


No comments:

Post a Comment