Seven-sided dice from five-sided dice with finite rolls

I have a 5-sided dice, and I want to use it to simulate a 7-sided dice. Is there a way to do this with a finite number of rolls?


There is no way to do it with a bounded number of rolls. This is because if you know you will stop after at most $k$ rolls, the probability of each outcome or combination of outcomes is a multiple of $\big(\frac15\big)^k$, but $\frac17$ isn't.

If you're ok with the number of rolls being unbounded, but finite with probability $1$, you can do this. For example, rolling two dice gives $25$ possible outcomes. Assign three each to the numbers $1$ to $7$, and if one of the other four outcomes comes up, reroll. (More efficient schemes exist.)

The average number of times you roll two dice with this is $\frac{25}{21}$, since the probability of stopping is $\frac{21}{25}$ at each attempt (see wikipedia). So the average number of dice you need is $\frac{50}{21}$.