RosettaCodeData/Task/Monty-Hall-problem/Forth/monty-hall-problem-2.fth
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

14 lines
350 B
Forth

0 value stay-wins
0 value switch-wins
: trial ( -- )
3 choose 3 choose ( -- prize choice )
= IF 1 +TO stay-wins exit ENDIF
1 +TO switch-wins ;
: trials ( n -- )
CLEAR stay-wins
CLEAR switch-wins
dup 0 ?DO trial LOOP
CR stay-wins DEC. ." / " dup DEC. ." staying wins,"
CR switch-wins DEC. ." / " DEC. ." switching wins." ;