4

Note this question is subtly different to the question Can I infinitely prepend a digit to some number and always get primes?. This question has previously been closed as a duplicate of that question - it is not!

That question aks for an infinite sequence of primes similar to the finite sequences I describe. I ask whether it is possible to find a finite sequence of length $k$, for all $k$, which is not the same thing. The sole answer on that question notable says it does not prove that there can't be a maximum such $k$, and so does not answer this question.


A famous "pattern" in the primes is

$$ \begin{align} 31 & \text{ is prime} \\ 331 & \text{ is prime} \\ 3331 & \text{ is prime} \\ 33331 & \text{ is prime} \\ 333331 & \text{ is prime} \\ 3333331 & \text{ is prime} \\ 33333331 & \text{ is prime} \end{align} $$

but this breaks at $333333331=17 \times19607843$.

Let's generalize this. Write $a \oplus b$ for the decimal concatenation of two numbers $a, b$, e.g. $12 \oplus 34 = 1234$.

Then for $a \in \{1,...,9\}$, $b \in \mathbb{N}$, we call $(a,b)$ a prepend prime pattern of length $k$ if $b$ is prime, $a \oplus b$ is prime, ..., $\underbrace{a \oplus \dots \oplus a}_{k-1} \oplus b$ is prime.

As an example, we have seen that $(3,31)$ is a prepend prime pattern of length $7$.


Question: can we find arbitrarily long finite prepend prime patterns? That is, for any $k \in \mathbb{N}$, can I find a prepend prime pattern of length $k$?

Here's what I've observed so far.

First, we can narrow down conditions on $a$ quite a bit. Let's observe that for a prepend prime pattern to be length $2$ or more with $b > 3$, we require $a \in \{3, 6, 9\}$. Indeed, we'll require, for $m$ the length of $b$ in decimal digits,

$$\begin{align} b & \text{ is prime} \\ a * 10^m + b & \text{ is prime} \\ a * 10^{m+1} + a * 10^m + b & \text{ is prime} \\ \end{align}$$

So, modulo $3$, we need $b, a+b, 2a+b \not \equiv 0 \mod 3$. We require that $b$ is prime, so the first is true, and if $3 \mid a$, then the rest are also true. But if $3 \not \mid a$, then we get $a \equiv \pm 1 \mod 3$ and deduce that one of $a+b, 2a+b \equiv 0 \mod 3$.

I used this to check by computer the total number of prepend prime patterns of length $3$ or more below $5 \times 10^7$. I found patterns of length $8$ and $9$ (beating $(3,31)$) but none of length $10$:

$k$ Prepend prime patterns of length $k$ (exactly) Prepend prime patterns of length $k$ or more
$3$ $234216$ $272853$
$4$ $34291$ $38637$
$5$ $4013$ $4346$
$6$ $282$ $333$
$7$ $44$ $51$
$8$ $6$ $7$
$9$ $1$ $1$

I suspect that the number of prepend primes of length $k$ or more below some number decays exponentially as $k$ increases. Indeed, within this data:

$k$ Prepend prime patterns of length $k$ or more Proportion of previous retained
$3$ $272853$ n/a
$4$ $38637$ $0.141603721$
$5$ $4346$ $0.112482853$
$6$ $333$ $0.076622181$
$7$ $51$ $0.153153153$
$8$ $7$ $0.137254902$
$9$ $1$ $0.142857143$

Very roughly, on average in the above data, about $13 \%$ of the prepend prime patterns are retained as we increase $k$ by $1$.

Heuristically then, I suspect that if the above proportions decay exponentially, it should be possible to find a prepend prime pattern of arbitrary length, it's just going to get increasingly hard to do so. This of course does not prove that this is the case.

Also, here are the solutions of length $\geq 7$ for $b \leq 5 \times 10^7$.

$k$ Prepend prime patterns $(a,b)$ of length $k$ (exactly)
$7$ $(3,31)$, $(3, 4549)$, $(3, 37013)$, $(6, 559667)$, $(3, 1827589)$, $(9, 2177297)$, $(9, 2261297)$, $(3, 2847839)$, $(6, 2940793)$, $(9, 3365617)$, $(3, 3606583)$, $(9, 4209859)$, $(6, 4855237)$, $(3, 5633867)$, $(9, 5864687)$, $(6, 5941049)$, $(6, 6055541)$, $(6, 6347707)$, $(3, 6742709)$, $(9, 8275459)$, $(6, 8616281)$, $(6, 9682997)$, $(6, 10281809)$, $(3, 12515779)$, $(9,14820899)$, $(6, 17024377)$, $(6, 17892377)$, $(6, 18586343)$, $(3, 23324297)$, $(6, 32240291)$, $(6, 33563039)$, $(6, 36680251)$, $(3, 38210987)$, $(3, 39890069)$, $(6, 39949517)$, $(9, 40615409)$, $(9, 42202813)$, $(9, 42268879)$, $(6, 42408953)$, $(9, 42908623)$, $(3, 43412309)$, $(3, 45672287)$, $(3, 46130017)$, $(9, 49531771)$
$8$ $(3, 7013)$, $(6, 347707)$, $(3, 8210987)$, $(6, 23233349)$, $(9, 39804473)$, $(6, 45556349)$
$9$ $(9, 4128253)$
Robin
  • 6,201
  • 2
    According to https://oeis.org/A186143 $26009371$ is the smallest suffix such that the numbers with $k$ digits "3" prepended are primes for $k=1,2,\dots,8$, which doesn't agree with your table. It also says $24680858269$ with $k$ digits $3$ prepended is prime for $k=1,2,\dots,10$. https://oeis.org/A186142 handles prepending nines, and https://oeis.org/A350216 handles sixes. – Gerry Myerson May 03 '25 at 13:41
  • @GerryMyerson That is also very subtly different. I start indexing at $0$, that sequence starts indexing at $1$. My first $8$-long sequence prepending $3$s is with $7013$ since $7013$ (with $0$ prepends of $3$) up to $33333337013$ (with $7$ prepends of $3$) are all prime. That says that $326009371$ (with $1$ prepend of $3$) up to $3333333326009371$ (with $8$ prepends of $3$) are all prime (and that $26009371$ is the first such integer). – Robin May 03 '25 at 13:46
  • 2
    So now the record is $k=11$ (for $24680858269$). I doubt brute-force will be able to push this much further, and I don't see any way to tackle this theoretically. Most likely this is not answerable with current knowledge. – anankElpis May 03 '25 at 13:57
  • Similar: https://math.stackexchange.com/questions/3264921/extending-prime-numbers-digit-by-digit-while-retaining-primality – Eric Towers May 03 '25 at 14:35
  • 1
    Please change your question as it uses k to mean two different things. From https://oeis.org/A186142 (9, 2181953771) is a prepend prime pattern of length 12. – Simon Goater May 03 '25 at 15:47
  • @Simon Goater Ah yes, my mistake. Clarified that. – Robin May 03 '25 at 15:48
  • 1
    FWIW I found (6, 844125093829) via brute force search, which is length 13. Note that the OEIS sequences linked to in earlier comments don't require the suffix to be prime like in your question. – Simon Goater May 04 '25 at 07:58
  • 1
    FWIW2 (6, 18178015044923) (3, 29081109754217) (6, 97812769336757) all yield sequences of 13 primes. If my not so rigorously tested search program is working correctly, there're no 9 prepending prime sequence of length 13 or more with prime suffix < 10^14. Also, there are no examples with prime suffixes below that limit of sequences of length 14 or more. – Simon Goater May 08 '25 at 11:06
  • 1
    FWIW3 I don't know if anyone cares to know, but I took this on as a challenging GPU programming exercise. Assuming my program is working correctly, (3, 1703540179976669) is the smallest case yielding a sequence of 14 primes, and (3, 36940672223924809) is the smallest case yielding a sequence of 15 primes. If there are cases of 16 primes, the suffixes must have at least 19 digits. – Simon Goater Jun 12 '25 at 19:44

0 Answers0