|
サイコロ連続n回、同じ目が出る確率
OPTION ARITHMETIC NATIVE
RANDOMIZE
DIM B(15)
LET L=100000000 !'試行回数
FOR I=1 TO L
LET COUNT=0
LET N=INT(RND*6+1) !'1投目
DO
LET A=INT(RND*6+1) !'2投目以降
IF A=N THEN
LET COUNT=COUNT+1
LET B(COUNT)=B(COUNT)+1
END IF
LOOP WHILE A=N
NEXT I
FOR I=1 TO 15
PRINT I;":";B(I),B(I)/L,1/6^I
NEXT I
END
-----------------------------------------------------
サイコロ連続 n回、同じ目出るまでの回数
OPTION ARITHMETIC NATIVE
RANDOMIZE
FOR N=1 TO 10 !'同じ目が連続 n回
LET I=0
DO
LET I=I+1
LET COUNT=0
LET NN=INT(RND*6+1)
DO
LET A=INT(RND*6+1)
IF A=NN THEN LET COUNT=COUNT+1
LOOP WHILE A=NN
LOOP UNTIL COUNT=N
PRINT N;":";I
NEXT N
END
|
|