Roll me a prime

Optimus Prime loves prime numbers . So, he decides to keep rolling a fair six-sided die, until he rolls a prime number less than 100. e.g. If his last two rolls were a 6 and then a 1, he would be done since 61 is a prime number. Or, for example, any time he rolls a 3 he would also be done since 3 is a prime number.

If the expected number of rolls he must make is a b \dfrac{a}{b} , where a a and b b are coprime positive integers , what is a + b a+b ?


Image credit: www.edplace.com


The answer is 11.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Geoff Pilling
Jul 23, 2016

Let E n = E_n = The expected number of remaining rolls given that n n was the last number rolled.

Since 2, 3, and 5 are all prime, clearly E 2 = E 3 = E 5 = 0 E_2 = E_3 = E_5 = 0 .

Also, the only two digit primes starting with 1, 4 or 6 and ending with 1, 4, or 6 are 11, 41, and 61. Translating this to a set of linear equations, you get:

  • E 0 = 1 + ( 1 / 6 ) E 1 + ( 1 / 6 ) E 4 + ( 1 / 6 ) E 6 E_0 = 1 + (1/6)*E_1 + (1/6)*E_4 + (1/6)*E_6
  • E 1 = 1 + ( 1 / 6 ) E 4 + ( 1 / 6 ) E 6 E_1 = 1 + (1/6)*E_4 + (1/6)*E_6
  • E 4 = 1 + ( 1 / 6 ) E 4 + ( 1 / 6 ) E 6 E_4 = 1 + (1/6)*E_4 + (1/6)*E_6
  • E 6 = 1 + ( 1 / 6 ) E 4 + ( 1 / 6 ) E 6 E_6 = 1 + (1/6)*E_4 + (1/6)*E_6

The above equations are derived by considering states 0 0 , 1 1 , 4 4 , and 6 6 labeled by what the last number you rolled is (except for 0 0 which is the state you start in). So, E n = E_n = The expected number of rolls from state n n . Then you can derive the above equations, for example for E 1 E_1 , from state 1 1 you use up 1 1 roll (the first term, 1 1 ) and you have 1 / 6 1/6 probability of getting to 4 4 or 6 6 . This translates to the second equation in the solution. You set up similar equations for 0 0 , 4 4 and 6 6 .

Solving for E 0 E_0 , you get, E 0 = 7 / 4 E_0 = 7/4

7 + 4 = 11 7+4 = \boxed{11}

I get the first 2 equations. Can't seem to get my head around the last 2. Any extra explanation?

Peter van der Linden - 4 years, 10 months ago

Simpler: if there has been at least one roll and we're still going, rolling a 1 is also a success, because the previous roll must be one of 1, 4, 6 and all of 11, 41, 61 are primes. Thus given that there is a previous roll, the expected number of rolls E E' satisfies E = 1 + 1 3 E E' = 1 + \frac{1}{3} E' , or E = 3 2 E' = \frac{3}{2} . At the beginning, there is no previous roll; either we roll 2, 3, or 5 and we win, or otherwise we need an expected number of 1 + E 1 + E' rolls (1 for the first roll, E E' for the rest).

Ivan Koswara - 4 years, 10 months ago

Log in to reply

Ah yes, very nice! ;)

Geoff Pilling - 4 years, 10 months ago

Log in to reply

And to finish off Ivan's logic here... E = 1 + ( 1 / 2 ) E = 1 + ( 1 / 2 ) ( 3 / 2 ) = 7 / 4 E = 1 +(1/2)E' = 1 + (1/2)(3/2) = 7/4 7 + 4 = 11 7+4=\boxed{11}

Geoff Pilling - 4 years, 10 months ago

Can you please explain how you got these equations? Thank you!

Ashish Sacheti - 4 years, 10 months ago

Consider states 0, 1, 4, and 6 labeled by what the last number you rolled is (except for 0 which is the state you start in). So, E n = The expected number of rolls from state n. Then you can derive the above equations, for example for E 1, from state 1 you use up 1 move (the first term, 1) and you have 1/6 probability of getting to 4, or 6. This translates to the second equation in the solution. You set up similar equations for 0, 4 and 6.

Make sense?

Geoff Pilling - 4 years, 10 months ago

Why is 3 not considered as the second number. 13 is prime.

Kevin Glentworth - 4 years, 10 months ago

You only consider non primes.

Geoff Pilling - 4 years, 10 months ago

The non primes for 4 are 44 and 46. You don't include 42 or 45 since 2 and 5 are prime.

Geoff Pilling - 4 years, 10 months ago

Same with 6.

Geoff Pilling - 4 years, 10 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...