Wednesday, October 6, 2010

Pi by chance

clg

in=0
color red
circle 150,150,150
color black
For dots = 1 to 10000
x=rand*300+1
y=rand*300+1
circle x,y,2
if ((x-150)^2+(y-150)^2)^.5<=150 then in=in+1
print in*4/dots
next dots

No comments:

Post a Comment