View difference between Paste ID: cbiHTWva and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
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 | } |