home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
coders
/
jËzyki_programowania
/
amigae
/
e_v3.2a
/
pdsrc
/
lang
/
yax
/
pi.yax
< prev
next >
Wrap
Lisp/Scheme
|
2001-03-31
|
732b
|
43 lines
(defun pi (nr)
(set max (* nr 4))
(array a max)
(set m nr)
(for i 0 max (set (a i) 0))
(set k (- (/ (* m 3321) 1000) 1) )
(for n k 1
(set (a 0) (+ (a 0) 2))
(set p (+ 1 (* 2 n)))
(set c 0)
(for i 0 m
(set c (+ (* 10 c) (* n (a i))))
(set (a i) (/ c p))
(set c (- c (* (a i) p)))
)
(locate 5 20)
(write n ' ' '')
)
(for i m 1
(if (greater (a i) 9)
(do
(set (a i) (- (a i) 10) )
(set (a (- i 1)) (+ (a (- i 1)) 1))
)
)
)
(cls)
(write)
(write 'pi=3.' '')
(for i 1 m
(write (a i) '')
)
(write)
)
(window 0 11 400 150 'PI calc')
(write '#of decimals: ' '')
(set deci (readint))
(write 'busy ....')
(pi deci)
(write)