Created
August 15, 2014 08:24
-
-
Save Ishibasystems/228f5f3a6d8cabc300ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 '---Monte Carlo method--- | |
110 SCREEN 3,0,0,1 | |
120 CLS 3 | |
130 RANDOMIZE VAL(RIGHT$(TIME$,2)) | |
140 N=10000 | |
150 COUNT=0 | |
160 FOR K=0 TO N | |
170 X=RND*2-1 | |
180 Y=RND*2-1 | |
190 IF X^2+Y^2<=1 THEN PSET(X*200+320,-Y*200+200),2 : COUNT=COUNT+1 ELSE PSET(X*200+320,-Y*200+200),1 | |
200 NEXT K | |
210 CIRCLE(320,200),200,4 | |
220 PRINT"N =";N | |
230 PRINT"COUNT=";COUNT | |
240 PRINT"ANS =";4*COUNT/N | |
250 PRINT | |
260 LIST | |
270 END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment