Just for fun, I am trying to find a good method to generate a random number between 1 and 10 (uniformly) with an unbiased six-sided die.

I found a way, but it may requires a lot of steps before getting the number, so I was wondering if there are more efficient methods.

My method:

- Throw the die and call the result $n$. If $1\leq n\leq 3$ your number will be between $1$ and $5$ and if $4\leq n\leq 6$ your number will be between $6$ and $10$. Hence, we reduced to the problem of generating a random number between $1$ and $5$.
- Now, to get a number between $1$ and $5$, throw the die five times. If the $i$th throw got the largest result, take your number to be $i$. If there is no largest result, start again until there is.
The problem is that although the probability that there will eventually be a largest result is $1$, it might take a while before getting it.

Is there a more efficient way that requires only some

fixednumber of steps?Edit:Or if not possible, a method with a smaller expected number of rolls?

**Answer**

You may throw the die many ($N$) times, take the sum of the outcomes and consider the residue class $\pmod{10}$. The distribution on $[1,10]$ gets closer and closer to a uniform distribution as $N$ increases.

You may throw the die once to decide if the final outcome will be even or odd, then throw it again until it gives an outcome different from six, that fixes the residue class $\pmod{5}$. In such a way you generate a uniform distribution over $[1,10]$ with $\frac{11}{5}=\color{red}{2.2}$ tosses, in average.

If you are allowed to throw the die in a wedge, you may label the edges of the die with the numbers in $[1,10]$ and mark two opposite edges as “reroll”. In such a way you save exactly one toss, and need just $\color{red}{1.2}$ tosses, in average.

Obviously, if you are allowed to throw the die in decagonal glass you don’t even need the die, but in such a case the lateral thinking spree ends with just $\color{red}{1}$ toss. Not much different from buying a D10, as Travis suggested.

At last, just for fun: look at the die, without throwing it. Then look at your clock, the last digit of the seconds. Add one. $\color{red}{0}$ tosses.

**Attribution***Source : Link , Question Author : P.A. , Answer Author : wythagoras*