# Expected value with nine-sided die

You have a fair nine-sided die, where the faces are numbered from $$1$$ to $$9.$$ You roll the die repeatedly, and write the number consisting of all your rolls so far, until you get a multiple of $$3.$$ For example, you could roll an $$8,$$ then a $$2,$$ then a $$5.$$ You would stop at this point, because $$825$$ is divisible by $$3$$, but $$8$$ and $$82$$ are not.

Find the expected number of times that you roll the die.

I am fairly new to the concept of expected value, and I don't really know how to go about solving this. It would be great if someone could help.

A number is divisible by 3 if and only if the sum of its digits are divisible by 3. Also, note that rolling a die with nine sides, we always have a 1 in 3 chance of getting a number that makes the sum divisible by 3 (because of the 9 values the sum could take, 3 must be divisible by 3). This is independent of the value we're currently at, so this is just a geometric random variable with $$p=1/3$$ and the expected number of trials is $$E(X) = 1/p = 3$$
• If I remember correctly $E[X]=\frac{1-p}p$ – Shubham Johri Dec 10 '19 at 22:25
• To add on to your answer, whenever we don't get a number divisible by $3$, we arrive at a number that is equivalent to $1$ or $2$ modulo $3$. In the first case, we need to roll a number that is equivalent to $2$ modulo $3$; in the latter, we need a number equivalent to $1$ modulo $3$. In both situations we have a $1/3$ chance to create a number that is divisible by $3$, which is why it is independent of the value we are currently at. (+1) – WaveX Dec 10 '19 at 22:27