fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. Scanner in = new Scanner(System.in);
  11. int k;
  12. double val = 0;
  13. k = in.nextInt();
  14. for (int n = 1; n <= k; n++){
  15. val += 1.0/((3*n - 2)*(3*n + 1));
  16. }
  17. System.out.println(val);
  18. }
  19. }
Success #stdin #stdout 0.13s 29544KB
stdin
100000
stdout
0.3333117506971819