Most popular lottery is the 5 in Hungary, where you win the jackpot if you find 5 numbers exactly out of 90. Couple years ago I saw a very creative code solution on hup, so I save it here. Can you do the lottery draw easier?
int m,i;
for(m=5,i=90;i>;0;--i)
if(rand()%i<;m) {
printf(“%d\n”,91-i); --m;
}
Do not forget, that rand() is generating pseudo-random number, so for a real lottery it cannot be used. I simulated the distribution for big numbers, because my mind was so against it, and it worked well (not my mind, of course it did, too, but the code). Paradoxon of Monty Hall is kind of the same type of mindblowing problems with extremely easy math.