Skip to content

Instantly share code, notes, and snippets.

@jed
Created June 12, 2011 12:41
Show Gist options
  • Save jed/1021505 to your computer and use it in GitHub Desktop.
Save jed/1021505 to your computer and use it in GitHub Desktop.
testing the randomness of (new Date % n)
#!/usr/local/bin/node
var i = 1000
, ret = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
!function calc() {
var rand = new Date % ret.length
return i--
? setTimeout(calc, rand+20) && ret[rand]++
: console.log(ret)
}()
[ 109,
16,
18,
1,
154,
20,
41,
0,
155,
29,
20,
0,
155,
40,
29,
0,
155,
29,
29,
0 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment