fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main() {
  6. int k;
  7. long double val = 0;
  8. cin >> k;
  9. for (int n = 1; n <= k; n++){
  10. val += 1.0/((3*n - 2)*(3*n + 1));
  11. }
  12. cout << setprecision(15) <<val;
  13. return 0;
  14. }
Success #stdin #stdout 0s 4508KB
stdin
10000
stdout
0.33332222259258