Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: Java  |  size: 0.56 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }