32 lines
434 B
C++
32 lines
434 B
C++
#include <iostream>
|
|
#include <iomanip>
|
|
#include <cmath>
|
|
using namespace std;
|
|
|
|
double silnia(int a){
|
|
int i,b=1;
|
|
for(i=1;i<=a;i++){
|
|
b*=i;
|
|
}
|
|
return b;
|
|
}
|
|
|
|
int main(){
|
|
double eps,liczba=1,pom;
|
|
int i=1;
|
|
cin>>eps;
|
|
do{
|
|
pom=liczba;
|
|
liczba=pom+1/silnia(i);
|
|
i++;
|
|
}while(abs(liczba-pom)>eps);
|
|
|
|
int prec=1;
|
|
while(eps!=1){
|
|
eps=eps*10;
|
|
prec++;
|
|
}
|
|
cout<<setprecision(prec)<<liczba;
|
|
return 0;
|
|
}
|