Monty Hall problem: Difference between revisions
Content added Content deleted
(→{{header|JavaScript}}: Output?) |
m (→{{header|JavaScript}}: whitespace) |
||
Line 1,130: | Line 1,130: | ||
{{output?|Javascript}} |
{{output?|Javascript}} |
||
<!-- http://blog.dreasgrech.com/2011/09/simulating-monty-hall-problem.html --> |
<!-- http://blog.dreasgrech.com/2011/09/simulating-monty-hall-problem.html --> |
||
<lang javascript> |
<lang javascript>var totalGames = 10000, |
||
var totalGames = 10000, |
|||
selectDoor = function () { |
selectDoor = function () { |
||
return Math.floor(Math.random() * 3); // Choose a number from 0, 1 and 2. |
return Math.floor(Math.random() * 3); // Choose a number from 0, 1 and 2. |
||
Line 1,174: | Line 1,173: | ||
console.log("Playing " + totalGames + " games"); |
console.log("Playing " + totalGames + " games"); |
||
console.log("Wins when not switching door", play(false)); |
console.log("Wins when not switching door", play(false)); |
||
console.log("Wins when switching door", play(true)); |
console.log("Wins when switching door", play(true));</lang> |
||
</lang> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |