I think this is the most efficient way to emulate an n-sided die with an m-sided die.

Imagine that you need an n-sided die to for instance choose between n things to do, but only have an m-sided die. If for instance n=2 and m=6, you can only take M(modulo 2) + 1, where M is the result from throwing your m-sided die. If n=5 and m=6, you reroll the die if M=6. However, this makes it necessary to possibly toss the die more than one time. Expected number of throws is 1 + 1/6 + 1/36 + ... = 6/5.

In order to emulate the n-sided die most efficiently, find the lowest integer x such that m^x≥ n. Let a be the integer part of (m^x)/n.

Now the actuall tossing begins.
1. Toss the m-sided die x times and note down the results M1, M2, M3 ... Mx.
2. Let Q = M1 + M2*m + M3*m^2 + ... + Mx*m^(x-1).
3. If Q> n*a, go back to step 1.
4. When you get a value of Q≤ n*a, your n-sided die result can be calculated by taking Q(modulo n) + 1.