fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main(){
  6. double exponent = M_E, a = sqrt(2)/exponent, sum = 0, E;
  7. cin >> E;
  8. for (int i = 1; (a = sqrt(i+1)/(i * exponent)) >= E; i++){
  9. exponent *= M_E;
  10. sum += a;
  11. }
  12. cout << sum;
  13. return 0;
  14. }
Success #stdin #stdout 0s 3416KB
stdin
0.00001
stdout
0.685841