+ 12

# How to compute the series?

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

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);

+ 9

thank you

+ 12

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

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);

+ 9

thank you