0

Need help with this programme( sum of series )

Find the sum of the series:- x^2+ x^4/3!+ x^6/5!+..... x^2n/ (2n-1)! I used a nested for loop for this. First i declared f= 1 for the factorial and then i declared sum=0. My for statements were like this. for i in range(1,n+1): for j in range(1,2*i): f*=j sum+=x**2*i/f But I'm getting the wrong output every time. What correction should I make in my code? Please reply ASAP

18th Aug 2019, 6:18 AM
Sriya
5 Respuestas
+ 1
I guess you have to reset f after your iterarion? :) After adding your element to the sum you should write f=1
18th Aug 2019, 6:49 AM
Tom Hammerbacher
Tom Hammerbacher - avatar
+ 1
All right. Thank you!
18th Aug 2019, 6:51 AM
Sriya
0
Use recursion and for reducing time complexity you can also use Horner's rule
18th Aug 2019, 6:26 AM
Rishab Sharma
Rishab Sharma - avatar
0
I don't know what that is. I'm a beginner in Python. Can you please explain?
18th Aug 2019, 6:37 AM
Sriya
0
when a function calls itself then it's recursion. And you must learn it because you can solve any complex problem very easily
18th Aug 2019, 6:40 AM
Rishab Sharma
Rishab Sharma - avatar