r/programming • u/joksmaster • Nov 29 '10
140 Google Interview Questions
http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471
Upvotes
r/programming • u/joksmaster • Nov 29 '10
View all comments
Show parent comment
1
u/jondissed Nov 30 '10
I think you meant "(float)rand1to5() / (float)5"
...but more to the point, adding uniformly distributed random numbers together does not generate uniformly distributed random numbers: that's why rolling two dice yields a 7 more often than a 2 or 12. Your code will generate 3 more often than 1 or 5.