Computer Science, asked by BanglarGorbo, 1 month ago

(Python)Find sum of factorial series: x-x^2/2!+X^4/4!-x^6/6!.......n

Answers

Answered by BrainlyProgrammer
4

Question :-

  • WAP in python to find the sum of the series

x - x^2/2! + x^4/4! - x^6/6!....nth term

Code Logic :-

  • Even terms are negative and odd terms are positive
  • numerator = x raised to power i
  • denominator= factorial of i

Variable Description :-

  1. f:- to calculate factorial of i
  2. j:- loop variable
  3. i:- loop variable
  4. n:- to Accept no. of terms from the user
  5. x:- to accept value of 'x' from the user
  6. s:- to calculate sum

Code Explanation :-

  1. the program accepts the no. of terms and the value of x from the user
  2. f and s are initialized to 1 and 0 respectively
  3. Then the program runs i Loop from 1 to n
  4. Then it run j loop from 1 to i to calculate factorial of I
  5. if I loop Value is even then it substract the terms from its previous value
  6. else if I loop value is odd then it adds the terms
  7. when I loop value becomes greater than n then loop terminates
  8. sum gets printed
Attachments:
Similar questions