home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 19 / 019.d81 / calc.pi (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1986-01-01  |  930 b   |  40 lines

  1. 10 ifx=0thenx=1:load"sysplotterd.o",8,1
  2. 20 sys49158:gosub400
  3. 60 :
  4. 70 sys49173,0,0,0,150
  5. 72 sys49173,0,150,180,150
  6. 74 sys49173,180,150,180,0
  7. 76 sys49173,180,0,0,0
  8. 78 :
  9. 80 radius=180*180
  10. 82 ix=0:iy=150
  11. 84 forx=0to180step3
  12. 86 y=sqr(radius-x^2)*5/6
  13. 88 sys49173,ix,iy,x,y:ix=x:iy=y
  14. 90 next
  15. 92 sys49179,"press a key to see current value",0,180
  16. 93 sys49179,"(press 'q' to quit)",0,190
  17. 95 :
  18. 100 fori=1to1000000
  19. 102 x=rnd(2):y=rnd(2):ifx*x+y*y<1thens=s+1
  20. 104 ifx<.5thenlx=lx+1
  21. 106 ify<.5thenly=ly+1
  22. 108 x=x*180:y=y*150:sys49167,x,y
  23. 110 ifi>1thenpi=4*s/(i-1)
  24. 112 ifpeek(198)>0thengosub300
  25. 114 next
  26. 120 pi=4*2/(i+1)
  27. 130 gosub1000
  28. 140 print"[147]1,000,000 plots ==>"pi
  29. 145 print"press a key to return to loadstar."
  30. 150 poke198,0:wait198,1:geta$
  31. 160 load"hello connect",8:end
  32. 300 rem   see answer
  33. 305 geta$:ifa$="q"thensys49155:print"[147]":load"hello connect",8:end
  34. 310 sys49155:print"[147]"chr$(142)
  35. 320 print"pi is approximated by"pi:print"in"i"iterations."
  36. 330 print"press a key to continue..."
  37. 340 poke198,0:wait198,1:geta$
  38. 350 gosub400:return
  39. 400 sys49161,1:sys49164,0:sys49152:return
  40.