Back to General discussions forum
Here's what the description says: "Divide the random value R by the N (number of distinct values we want - e.g. 6 for dice) and take the remainder. This remainder is necessarily the integer value in the range from 0 to N - 1." No it isn't. The numbers from the example are:
193170145 1912748246
753156389 614113621
1824520917 53700559
1288077384 911939603
1939066598 1695763253
1905581606 1811712139
878644967 1090885451
and their reminders are (after dividing by 6):
0.1666666679084301 0.3333333134651184
0.8333333283662796 0.1666666716337204
0.5 0.16666666604578495
0.0 0.8333333432674408
0.3333333134651184 0.8333333134651184
0.3333333134651184 0.1666666865348816
0.8333333432674408 0.8333333432674408
So they are in range nowhere near 0 to 5.
When we talk about remainders, we imply integer division (i.e., in Python R // N
, as opposed to R / N
) and not the fractional part.
What you need is R % N
.
Ah, I see. A bit confusing phrasing, don't you think?