Quote:

rand5() + 5*rand5() + 25*rand5() + 125*rand5() + 625*rand5() + 3125*rand5() + 15625*rand5() - 19531) % 7) + 1



is nothing but
Code:
(very_large_nuber)%7+1

which is
Code:
rand()%7+1


of course that's correct, but why would you need 7 function calls, 6 multiplicatios... for such a simple task? you do not really use rand5(), it's only a factor to make your factor in the brackets bigger, you could have used rand6(), rand9() etc. without any change in the result.