Advertisement
linesguy

6 Pi Calculators

Jan 11th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. 1 text : home: ?"Which do you want to run?":?"1. Monte Carlo Method":?"2. Wallis Product":?"3. Riemann Zeta Function":?"4. Machin-like formula (Kikuo Takano)":?"5. Leibniz formula":?"6. Nilakantha's series" :input calc
  2. 10 if calc <> 1 goto 40 : rem Monteo Carlo Method
  3. 20 if rnd(1)<0.7853981634 then X = X + 1
  4. 30 Y = Y + 1 : ?(X/Y)*4 : goto 20
  5. 40 if calc <> 2 goto 70 : rem Wallis Product
  6. 50 pi = 2 :y = 1
  7. 60 X = X + 2 : pi = pi * (X/Y) : Y = Y + 2 : pi = pi * (X/Y) : ?pi :goto 60
  8. 70 if calc <> 3 goto 90 : rem Riemann Zeta Function
  9. 80 x = x + 1 : pi = pi +(1/(X^2)) : ?sqr(pi*6) : goto 80
  10. 90 if calc <> 4 goto 110 : rem Machine-like formula (by Kikuo Takano 1982)
  11. 100 print (12*atn(1/49)+32*atn(1/57)-5*atn(1/239)+12*atn(1/110443))*4 : goto 100
  12. 110 if calc <> 5 goto 140 : rem Leibniz formula
  13. 120 pi = 1 : x = 3
  14. 130 pi = pi - 1/x : pi = pi + 1/(x+2) : x = x + 4 : ?pi*4:goto 130
  15. 140 if calc <> 6 goto 170 : rem Nilakantha's series
  16. 150 pi = 3 : X = 2
  17. 160 pi = pi + 4/((X)*(X+1)*(X+2)) : pi = pi - 4/((X+2)*(X+3)*(X+4)) : ?pi : x = x + 4 : goto 160
  18. 170 input "Re-enter";calc : goto 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement