you are right! mine doesn't give equal probabilites. here is a simple python test script:
Code:
import random
def rand5():
return int((random.random() * 5) + 1)
##def rand7():
## return (rand5()+rand5()+rand5()+rand5()+rand5() - 2) / 3
def rand7():
answer = 27
while answer > 26:
answer = rand5() + rand5() * 5
return (answer - 5) % 7 + 1
count = {}
for i in range(1000000):
r = rand7()
if count.has_key(r):
count[r] += 1
else:
count[r] = 1
print count
your version works! but is a version without while or if possible?

<edit>hm... i am not sure but this one seems to work:
Code:
def rand7():
return ((rand5() +
5*rand5() +
25*rand5() +
125*rand5() +
625*rand5() +
3125*rand5() +
15625*rand5() - 19531) % 7) + 1
i only found this with some trial and error though!

</edit>