include<iostream> using namespace std; #include<cmath> void main() { int x=1; float n=1.0,t=1,sum=0; do{ t=1/n; sum+=t; n=n*(x++); }while((fabs(t))>1e-6); cout<<"e="<<sum<<endl; }
#include <iostream> using namespace std; int main( void ) { double e = 0; for( unsigned i=0,f=1; f<1000000; f*=++i ) e += 1.0/f; cout << "e = " << e << endl; }