19 lines
293 B
C++
19 lines
293 B
C++
|
#include<iostream>
|
||
|
#include<iomanip>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
int main(){
|
||
|
double e = 1.0;
|
||
|
double factorial = 1.0;
|
||
|
|
||
|
for (int i = 1; i <= 20; i++)
|
||
|
{
|
||
|
factorial *= i;
|
||
|
e += 1.0 / factorial;
|
||
|
}
|
||
|
|
||
|
cout << fixed << setprecision(3) << e << endl;
|
||
|
|
||
|
return 0;
|
||
|
}
|