Guest User

Untitled

a guest
Feb 26th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. public class t1
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         double pi4=0;
  6.         int len,zec=Integer.parseInt(args[0]);
  7.         long i,u,t=System.currentTimeMillis();
  8.         for (i=0;i<=Integer.MAX_VALUE;i++)
  9.         {
  10.             pi4=(Math.pow(-1,i))/(2*i+1)+pi4;
  11.             len=Double.toString(pi4*4).length();
  12.             if (len==zec+2) break;
  13.         }
  14.         u=System.currentTimeMillis();
  15.         System.out.println("Pi cu "+zec+" zecimale este "+pi4*4);
  16.         System.out.print("Timpul total de executie este de "+(u-t)+" milisecunde.");
  17.     }
  18.  
  19. }
Add Comment
Please, Sign In to add comment