fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. int n, a=1, as=a, b=1;
  11. double sum=0.0, u=2.0;
  12. n = in.nextInt();
  13. for(int i=1, k=2; i<=n; i++, k++)
  14. {
  15. a=3*b+2*a;
  16. b=2*as+b;
  17. u*=(2.0/k);
  18. sum+=u*(1.0/(1+a*a+b*b));
  19. as=a;
  20. }
  21. System.out.printf(Locale.US, "%.8f", sum);
  22. }
  23. }
Success #stdin #stdout 0.17s 321344KB
stdin
4
stdout
0.05973395