Unbiased random number generator
Here is the algorithm for $n=10$.


Throw the dice twice to get $(x,y)$. 
Compute $r=x + 6(y-1)$. If $r\le10$, return $r$ and stop.
If we have reached here, go back to step 1.


Here is the algorithm for general $n$.


Compute $n=\lceil \log_6k\rceil$.
Throw the dice $n$ times to get $(x_1, x_2, \cdots, x_n)$. 
Compute $r=x_1+6(x_2-1)+6^2(x_3-1)+\cdots+6^{n-1}(x_n-1)$. If $r\le k$, return $r$ and stop.
If we have reached here, go back to step 2.




There are many variations, of course. 

For example, in step 2 for $n=10$, we can return $r=10 - (x + 6(y-1))\%10$ and stop  when $x+6(y-1)\le30$ instead. This will reduce the chance to go to step 2. Here % is the remainder operator.

For example, here is gnasher729's algorithm for $n=10$. Throw a dice until we get a number $x\not=6$. Throw the dice once more to get another number $y$. Return ((x - 1) * 6 + (y - 1))%10+1$.



(Exercise 1.) (One minute or less) Devise an algorithm for $n=3$. 

(Exercise 2.) Devise an algorithm for $n=7$. Try making its expected number of rolls as small as possible.

(Exercise 3.) Prove that the expected number of rolls in gnasher729's algorithm is the minimum among all algorithms.



(Exercise 4.) Given any $n&gt;1$, devise an algorithm with the least expected number of rolls.