Computer Science

Write programs to find the sum of the following series:

x + x2/2 + x3/3 + …… + xn/n (Input x and n both)

Python

Python Control Flow

40 Likes

Answer

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

sum = 0

for i in range(1, n + 1) :
    term = x ** i / i
    sum += term

print("Sum =", sum)

Output

Enter the value of x: 2
Enter the value of n: 5
Sum = 17.066666666666666

Answered By

21 Likes


Related Questions