Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class t1
- {
- public static void main(String[] args)
- {
- double pi4=0;
- int len,zec=Integer.parseInt(args[0]);
- long i,u,t=System.currentTimeMillis();
- for (i=0;i<=Integer.MAX_VALUE;i++)
- {
- pi4=(Math.pow(-1,i))/(2*i+1)+pi4;
- len=Double.toString(pi4*4).length();
- if (len==zec+2) break;
- }
- u=System.currentTimeMillis();
- System.out.println("Pi cu "+zec+" zecimale este "+pi4*4);
- System.out.print("Timpul total de executie este de "+(u-t)+" milisecunde.");
- }
- }
Add Comment
Please, Sign In to add comment