About series....

Hello, may someone tell me how to approach this problem: write a program to find e where e=1+1/2!+1/3!+1/4!+.....1/n!. I'm struggling with since i was absent during that lesson and I know you guys are not supposed to solve H.Ws but i just a way to approach it. Thank you.
and i also dont know what this ! sign mean?

Last edited on
follow the example at the end of this tutorial

http://www.cplusplus.com/doc/tutorial/functions/

You should use a loop to calculate a certain number of the terms in the series. Note that the ! represents the factorial function.
Thank you guys for replying but i looked at the end of that tutorial the code was a bit unclear.
zhuge i will try using for loop for that.
I think it works! yaaay
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()[
{
	int n, i;
	double factorial = 1,e;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		factorial *= i;
		e = 1 + 1 /factorial*n;

	}		
	cout << "E = " << e << endl;

}
Topic archived. No new replies allowed.