Last active
June 12, 2016 19:37
-
-
Save msteckyefantis/5d5d662bd5d09eddee7c0418a710bbd7 to your computer and use it in GitHub Desktop.
Super Mysterious Math!!!
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
'use strict'; | |
var M = Math; | |
var L = [ 0, 0 ]; | |
function F() { | |
return M.floor( 2 * M.random() ) ? 'head' : 'tail'; | |
} | |
function C() { | |
if( F() === 'head' ) { | |
L[0]++; | |
} | |
else{ | |
L[1]++; | |
} | |
} | |
for( var i = 0; i < 1000000; i++ ) { | |
C(); | |
} | |
console.log( L ); | |
/* | |
[ 499330, 500670 ] | |
[ 500252, 499748 ] | |
[ 499094, 500906 ] | |
[ 499657, 500343 ] | |
[ 500027, 499973 ] | |
[ 499850, 500150 ] | |
[ 499265, 500735 ] | |
[ 500282, 499718 ] | |
[ 499473, 500527 ] | |
[ 499963, 500037 ] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See vandium for AWS Lambda code security and validation!