Number of ways in arranging $5$ $6$-sided dices such that the digits on the 'top faces' form a $5$-digit prime, whose sum of its digits is prime?

54 Views Asked by At

Suppose we have $5$ $6$-sided fair dices. As the title suggests, how can one find the number of ways in arranging these $5$ dices such that the digits on the 'top faces' of the dices form a $5$-digit prime number, whose sum of its digits are prime as well?

What do you guys think? I thought of first finding the number of possible outcomes without restrictions, but got stuck after that as I do not know how to 'filter' out the outcomes that are not prime. Also, is there another way of doing this, such as by using generating functions?

Additional question (edit): Is there a way to generalize this for $n$ digits, whose sum is prime?

1

There are 1 best solutions below

4
On BEST ANSWER

So we want the number of $5$-digit primes, where each digit is between $1$ and $6$ (inclusive), and where the sum of digits is also prime. It seems to me like brute force is the way to go. I think, however, that beginning with the sum of digits is the best approach, as I think that going in that direction generates the fewest large numbers for us to check the primality of.

For instance, the sum of digits has to be between $5$ and $27$ because you're doing this with dice, and the final die must be $1$ or $3$. That leaves six possible primes: $5, 7, 11, 13, 17, 19$ and $23$. With the restriction that the last die must show $1$ or $3$, I don't think there are too many possible cases to check.

I can do the second easiest one to show what I'm tinking: $7$. A digit sum of $7$ is made up of either four $1$'s and a $3$, or three $1$'s and two $2$'s:

  • $1$'s and a $3$: There are five numbers to check: $31111, 13111, 11311, 11131$ and $11113$. Of these, $11311, 11131$ and $11113$ are prime, so we get $3$ numbers.

  • $1$'s and $2$'s. There are six numbers to check: $22111, 21211, 21121, 12211, 12121$ and $11221$. Of these, only $12121$ and $11221$ are composite, so we get $4$ more primes this way.

PS. I would love for there to be a less brute-forcy method. However, when dealing with restrictions on digits and other stuff that is base-dependent, and at the same time mix primes into it, then finding good, systematic approaches is usually difficult. The basic reason for this is that bases are additive in their nature, and primes are multiplicative in their nature, and the reason number theory is even the tiniest bit interesting is that addition and multiplication obstruct one another. For more famous examples of this phenomenon, see the difficulty of proving the $abc$-conjecture or Fermat's last theorem.