How do I randomly choose a number in a smaller range than what my random number generator produces?

558 Views Asked by At

My uniform random number generator can only produce integers in the range $0 \leq n \leq 255$. I need to use the output from this random number generator to generate another uniformly random integer in the range $0 \leq m \leq 209$. How can I do this?

Context: I need to randomly select an item from a list of 210 items using a random number supplied to me in the form of 8 random binary digits. I cannot change the range of the random number supplied to me.

EDIT: Some of the helpful comments suggest that I should use "rejection sampling". However, I would prefer a solution that has a guarantee on its maximum running time when implemented in a computer program.