So, no valid answer yet?

How about this?
Code:

int rand7()
{
int x;
do
{
x = ((rand5()+5*rand5())-5);
} while(x>21);
return ((x%7)+1);
}



Again, top of my head. But it gives equal probability (no dice effect).
I do not like the loop, but it is quicker than finding the LCD.

Last edited by Doug; 10/29/07 20:19.

Conitec's Free Resources:
User Magazine || Docs and Tutorials || WIKI