# Prime number construction game

This is a variant of Prime number building game.

Player $$AA$$ begins by choosing a single-digit prime number. Player $$BB$$ then appends any digit to that number such that the result is still prime, and players alternate in this fashion until one player loses by being unable to form a prime.

For instance, play might proceed as follows:

• $$AA$$ chooses 5
• $$BB$$ chooses 3, forming 53
• $$AA$$ loses since there are no primes of the form 53x

Is there a known solution to this game? It seems like I might be able to try a programmatic search…or might some math knowledge help here?

• If the first player starts with $$22$$, move to $$2929$$, and then all the moves are forced until you win at $$2939999929399999$$
• If the first player starts with $$33$$, move to $$3737$$. If they then move to $$373373$$, move to $$37333733$$ and you will win no matter what (at either $$3733799937337999$$ or $$373393373393$$). If they instead move to $$379379$$, you move to either $$37933793$$ or $$37973797$$ and win immediately.
• If the first player starts with $$55$$, move to $$5353$$ and win.
• If the first player starts with $$77$$, move to $$7171$$ and then every move is forced until you win at $$719333719333$$.
As a heuristic for why it should not be surprising that the game is so limited, note that by the prime number theorem, there are about $$NlogN\frac{N}{\log N}$$ primes less than $$NN$$, so the probability of a random $$nn$$-digit number being prime is about $$1log(10n)=1nlog(10)\frac{1}{\log(10^n)}=\frac{1}{n\log(10)}$$. Assuming that the primality of a number is independent from the primality of a number obtained by adding a digit at the end (which seems like a reasonable heuristic assumption), this gives that there are about $$10log(10)\frac{10}{\log(10)}$$ $$11$$-digit numbers that are valid positions in this game, and then $$10log(10)⋅102log(10)\frac{10}{\log(10)}\cdot\frac{10}{2\log(10)}$$ $$22$$-digit numbers, and in general $$10nn!log(10)n\frac{10^n}{n!\log(10)^n}$$ $$nn$$-digit numbers. Adding up all the valid positions (including the empty string at the start) gives about $$∞∑n=010nn!log(10)n=e10/log(10)≈77\sum_{n=0}^\infty\frac{10^n}{n!\log(10)^n}=e^{10/\log(10)}\approx 77$$ total positions. In fact, this heuristic estimate is not far from the actual value, which is $$8484$$.