Could someone explain how? I don't grok the command. My best guess is this relates to hexadecimal.
R % 10 + 1
The problem is that 10 does not evenly divide 256, hence for large R, the mapping will be incomplete. Specifically, 250 => 1
251 => 2
252 => 3
253 => 4
254 => 5
255 => 6
with no more random numbers available to yield results 7, 8, 9 and 10. R * 10 / 256 + 1
EDIT: I am wrong, this still has bias.And indeed this is how Python does it
https://github.com/python/cpython/blob/e37ac5fbb6de593521cf2...
https://github.com/python/cpython/blob/e37ac5fbb6de593521cf2...