i tend to think it's not possible at all since both 5 and 7 are prime numbers and rand5 can't return 0.

edit: ok, i found a way... at least all numbers are equally probable here. not very elegant, though.
Code:
short int rand7()
{
short int temp = 0;

for (int i = 0; i < 8; i ++) {
temp += rand5()-1;
}

if (temp == 32) {
return rand7();
}

return temp/4+1;
}



Last edited by Joey; 10/22/07 16:27.