Computer Science
Write programs to find the sum of the following series:
x - x2/2! + x3/3! - x4/4! + x5/5! - x6/6! (Input x)
Python
Python Control Flow
84 Likes
Answer
x = int(input("Enter the value of x: "))
sum = 0
m = 1
for i in range(1, 7) :
fact = 1
for j in range(1, i+1) :
fact *= j
term = x ** i / fact
sum += term * m
m = m * -1
print("Sum =", sum)
Output
Enter the value of x: 2
Sum = 0.8444444444444444
Answered By
30 Likes
Related Questions
Write a Python program to sum the sequence:
1 + 1/1! + 1/2! + 1/3! + ….. + 1/n! (Input n)
Write a program to accept the age of n employees and count the number of persons in the following age group:
(i) 26 - 35
(ii) 36 - 45
(iii) 46 - 55Write programs to find the sum of the following series:
x + x2/2 + x3/3 + …… + xn/n (Input x and n both)
Write programs to print the following shapes:
*
* *
* * *
* *
*