How to compute the series? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 12

How to compute the series?

s=x+x^2/2!+x^4/4!+x^6/6!+...+x^n/n!

7th Apr 2017, 7:38 PM
Safiya Yunus
Safiya Yunus - avatar
2 Answers
+ 5
Define a function "fact" to calculate factorial. Then, for (int i = 1; i <= n; i++) s += Math.pow(x, i) / fact(i);
8th Apr 2017, 1:29 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 9
thank you
8th Apr 2017, 2:08 AM
Safiya Yunus
Safiya Yunus - avatar