when i woke up this morning i realised that mine's still wrong -- it still suffers from dice syndrome.

ventilator, as elegant as your solution is, it suffers from the same problem.
there are, of course, 7 different possible results, but there are 5*5*5*5*5 = 3125 different ways to get those results. 7 is not a factor of 3125. of course, that's only a little sign that something does NOT have 7 results with equal probability. if it were divisible by 7, it wouldn't necessarily have avoided the problem i'm about to explain as follows:

a "1" will be returned whenever rand5()+...rand5()-2 < 6 (if i'm right in assuming that type conversion to integer doesn't round, but instead truncates the number). this will happen when rand5()+...rand5() < 8. now, it would take way too long to count out the number of combinations. but, it does require a result between 5-7, and that's the bottom range of this whole process. 5 can only be obtained the following way:
1+1+1+1+1
6 is much more likely to be obtained:
1+1+1+1+2
1+1+1+2+1
1+1+2+1+1
1+2+1+1+1
2+1+1+1+1
and as we get closer to the middle ((25-5+1)/2+5=15.5, which should be exactly halfway between 5 and 25) we get more possible combinations, and so the number with the highest probability of being obtained is (15-2)/3 = ~4, (16-2)/3 = ~4, because its rand5()+...+rand5() results need to be between 14-16, which have the highest number of combinations attributed to them.

which makes sense, of course, because 4 is exactly halfway between 1 and 7.

this basically explains the "dice syndrome" i mentioned earlier, which we're all yet to overcome.

julz


Formerly known as JulzMighty.
I made KarBOOM!