Draw integers independently & uniformly at random from 1 to $N$ using fair d6? I wish to draw integers from 1 to some specific $N$ by rolling some number of fair six-sided dice (d6). A good answer will explain why its method produces uniform and independent integers.
As an illustrative example, it would be helpful to explain how a solution works for the case of $N=150$.
Furthermore, I wish for the procedure to be as efficient as possible: roll the least number of d6 on average for each number generated.
Conversions from senary to decimal are permissible.

This question was inspired by this Meta thread.
 A: For the case of $N=150$, rolling a d6 three times distinctly creates $6^3=216$ outcomes.
The desired result can be tabulated in this way:


*

*Record a d6 three times sequentially. This produces results $a,b,c$. The result is uniform because all values of $a,b,c$ are equally likely (the dice are fair, and we are treating each roll as distinct).

*Subtract 1 from each.

*This is a senary number: each digit (place value) goes from 0 to 5 by powers of 6, so you can write the number in decimal using $$(a-1) \times 6^2 + (b-1) \times 6^1 + (c-1)\times 6^0$$

*Add 1.

*If the result exceeds 150, discard the result and roll again.


The probability of keeping a result is $p=\frac{150}{216}=\frac{25}{36}$. All rolls are independent, and we repeat the procedure until a "success" (a result in $1,2,\dots,150$) so the number of attempts to generate 1 draw between 1 and 150 is distributed as a geometric random variable, which has expectation $p^{-1}=\frac{36}{25}$. Therefore, using this method to generate 1 draw requires rolling $\frac{36}{25}\times 3 =4.32$ dice rolls on average (because each attempt rolls 3 dice).

Credit to @whuber to for suggesting this in chat.
A: Here is an even simpler alternative to the answer by Sycorax for the case where $N=150$.  Since $150 = 5 \times 5 \times 6$ you can perform the following procedure:

Generating uniform random number from 1 to 150:

*

*Make three ordered rolls of 1D6 and denote these as $R_1, R_2, R_3$.

*If either of the first two rolls is a six, reroll it until it is not 6.

*The number $(R_1, R_2, R_3)$ is a uniform number using positional notation with a radix of 5-5-6.  Thus, you can compute the desired number as:
$$X = 30 \cdot (R_1-1) + 6 \cdot (R_2-1) + (R_3-1) + 1.$$

This method can be generalised to larger $N$, but it becomes a bit more awkward when the value has one or more prime factors larger than $6$.
