#include <iostream>
#include <iomanip>
using namespace std;
int main()
{double fuc(int x);
double a,b=1;
a=fuc(b);
cout<<setprecision(10)<<"e="<<a;
return 0;
}
double fuc(int x)
{double p=1,q=1,sum=1;
while (p>=0.1e-10)
{double y=1,i=1;
while (i<=x)
{y=i*y;
i++;
}
p=q/y;
sum=sum+p;
x++;
}
return(sum);
}
网友评论