fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. double S = 0;
  7. cin >> n;
  8. for (int i = 1; i <= n; i++){
  9. S += 1.0/(i*(i + 1));
  10. }
  11. cout << S;
  12. return 0;
  13. }
Success #stdin #stdout 0s 4516KB
stdin
500
stdout
0.998004