Computer Science, asked by sukhanigautam2, 4 months ago

·        Write a program to input the value of x and n and print the sum of the following series:
1 +  {x}^{1}+x^{2} +  {x}^{3}  +  {x}^{4}   ...... {x}^{n}
SOLVE THIS CODE IN PYTHON

Answers

Answered by SP85
1

Here it is

def SUM(x, n):

total = 1

for i in range(1, n + 1):

total = total + ((x**i)/i)

return total

# Driver Code

x = 2

n = 5

s = SUM(x, n)

print(round(s, 2))

Similar questions