Created
April 20, 2017 12:53
-
-
Save Adals20/90e35456c53e06ec3ae500f46b9704d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
double factorial(double x); | |
double eee(double presicion){ | |
double x = 1, i = 0, y = 1, y1=0; | |
do{ | |
y1 = y; | |
y = y + (1/factorial(x)); | |
i++; | |
x++; | |
}while(abs(y-y1)>=presicion); | |
return y; | |
} | |
double factorial(double x){ | |
if (x == 0) | |
return 1; | |
else { | |
int recurso = factorial(x-1); | |
int res = x * recurso; | |
return res; | |
} | |
} | |
main(){ | |
double y, presicion; | |
cout << "Introdusca los numeros de presicion de la letra e: "; | |
cin >> presicion; | |
y = eee(presicion); | |
cout << "e con " << presicion <<" numeros de presicion es: "<< y << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment