Skip to content

Instantly share code, notes, and snippets.

@Adals20
Created April 20, 2017 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adals20/90e35456c53e06ec3ae500f46b9704d9 to your computer and use it in GitHub Desktop.
Save Adals20/90e35456c53e06ec3ae500f46b9704d9 to your computer and use it in GitHub Desktop.
#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