Euler's Number Loop

closed account (owCkSL3A)
I am trying to find Euler's Number to an accuracy inputted by the user in the form of (.001, .00001.....)

i believe my error is with the math and the start points but i cannot figure out where. Does anyone know and will point me to where i need to look at and change?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;



double fact(double& a);

void main()
{
	double acc;
	double dif;
	double i=1;
	double x = 1;
	double e;
	double e2=1;

	cin >> acc;

	do
	{
		i *= x;
		x++;
		e = 1 + 1 / i;

		dif = abs(e - e2);
			
		cout << endl << e << endl;
	} while (dif > acc);

	
		
	cout << e;


	system("pause");
	return;
}
The third post with the same topic :+(
Topic archived. No new replies allowed.