Created
April 21, 2017 19:12
-
-
Save eppfel/a1fd63aafcfcb9861a70e59bd315666a 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
var throwDice = function () { | |
return Math.floor(Math.random() * (6)) + 1; | |
}; | |
var results = [0,0,0,0,0,0]; | |
var iterations = 10000000; | |
for (var i = 0; i < iterations; i++) { | |
results[throwDice()-1]++; | |
} | |
for (var i = 0; i < results.length; i++) { | |
var percentage = results[i] / iterations * 100; | |
println((i+1) + ': ' + percentage + '%\n'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment