Advertisement
Guest User

Pi Calculator

a guest
May 28th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. package trp.pi;
  2.  
  3. public class Main {
  4. public static void main(String[] args){
  5.  
  6. double pi = 0;
  7. double x = 0;
  8.  
  9. do{
  10. x += 4;
  11. pi += (4 / (x-3)) - (4 / (x-1));
  12. System.out.println(x + " <- x ..... pi -> " + pi);
  13.  
  14. }while(x>-1);
  15.  
  16. System.out.println("pi = " + pi);
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement