Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- 10 if calc <> 1 goto 40 : rem Monteo Carlo Method
- 20 if rnd(1)<0.7853981634 then X = X + 1
- 30 Y = Y + 1 : ?(X/Y)*4 : goto 20
- 40 if calc <> 2 goto 70 : rem Wallis Product
- 50 pi = 2 :y = 1
- 60 X = X + 2 : pi = pi * (X/Y) : Y = Y + 2 : pi = pi * (X/Y) : ?pi :goto 60
- 70 if calc <> 3 goto 90 : rem Riemann Zeta Function
- 80 x = x + 1 : pi = pi +(1/(X^2)) : ?sqr(pi*6) : goto 80
- 90 if calc <> 4 goto 110 : rem Machine-like formula (by Kikuo Takano 1982)
- 100 print (12*atn(1/49)+32*atn(1/57)-5*atn(1/239)+12*atn(1/110443))*4 : goto 100
- 110 if calc <> 5 goto 140 : rem Leibniz formula
- 120 pi = 1 : x = 3
- 130 pi = pi - 1/x : pi = pi + 1/(x+2) : x = x + 4 : ?pi*4:goto 130
- 140 if calc <> 6 goto 170 : rem Nilakantha's series
- 150 pi = 3 : X = 2
- 160 pi = pi + 4/((X)*(X+1)*(X+2)) : pi = pi - 4/((X+2)*(X+3)*(X+4)) : ?pi : x = x + 4 : goto 160
- 170 input "Re-enter";calc : goto 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement