fork download
  1. /* package whatever; // don't place package name! */
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. /* Name of the class has to be "Main" only if the class is public. */
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. double a,x,q,s,e;
  12. x=0.2;
  13. e=0.000001;
  14. a=x;
  15. s=a;
  16. for (int n = 0;; n++)
  17. {
  18. q = (-1 * x*x*(2 * n + 1)) / (2 * n*n + 5 * n + 3);
  19. a *= q;
  20. s += a;
  21. if (a < e) break;
  22. }
  23. System.out.print(s*2/Math.sqrt(Math.PI));
  24. }
  25. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
0.22266682230684784