Number of primes within a number of given length

179 Views Asked by At

My question is most easily explained via an example: Consider the number $n=1967$. It contains the prime numbers $7$, $19$, $67$ and $967$ as all those are primes and you can find them in the decimal expansion of $1967$. In contrast, the part $196$ for example is not prime.

Given a fixed number of digits, $k$ say, what can be said about the maximal number of primes you can find in the decimal expansion of a $k$-digit number? I will call this number $m(k)$. The above example then teaches us that $m(4)\ge 4$.

Clearly, $m(k) \ge k$ e.g. by considering the number with digit $3$ $k$-times. The same argument shows that $m(k+1)\ge m(k)+1$. The maximal number of subnumbers for a $k$-digit number is $\frac{k(k+1)}{2}$, so trivially $m(k)\le \frac{k(k+1)}{2}$.

The first cases are: $$m(1)=1\ (e.g. n=3)\\ m(2)=3\ (e.g. n=23)\\ m(3)=6\ (e.g. n=373).$$

2

There are 2 best solutions below

3
On

I made a python script to check if the natural upper bound is always reached. The answer seems to be no:

Answer (for each $k$ from 1 to 5):

$[1, 3, 6, 9, 13]$

Natural upper bound (for each $k$ from 1 to 5):

$[1, 3, 6, 10, 15]$

3
On

Don't know how about digit '$0$' using (for example, $307$: $3, 7$, $\color{gray}{07}$(???) and $307$).
Therefore all examples below are without this digit.

Few bounds with examples:

\begin{array}{|c|c|c|l|} \hline k & m(k) & \frac{k(k+1)}{2} & examples \\ \hline 4 & 9 & 10 & ... \\ 5 & 13 & 15 & 31373, 37337 \\ 6 & 17 & 21 & 337397, 373373, 373379 \\ 7 & 22 & 28 & 3733797 \\ 8 & 26 & 36 & 37337397 \\ 9 & 30 & 45 & 113733797, 233133733, 373373977, 733133733 \\ 10 & 35 & 55 & 2113733797, 3733133733, 7331337337 \\ 11 & \ge 40 & 66 & 17331337337, 37331337337, 37337937337, 52379337397, ... \\ 12 & \ge 45 & 78 & 337331237337, 361373371973, 373312373373, 373313373379, ... \\ 13 & \ge 51 & 91 & 1117331337337, 3373312373373 \\ 14 & \ge 56 & 105 & 11173313373373, 31379719337397, 32917333739397, 33733123733739 \\ 15 & \ge 62 & 120 & 329173337393739, 337331237337397 \\ 16 & \ge 68 & 136 & 3291733373937397 \\ 17 & \ge 74 & 153 & 31973373312373373 \\ 18 & \ge 80 & 171 & 331973373312373373 \\ 19 & \ge 85 & 190 & 1373363733123733739, 1731373973373937397, 2331127997337337973, ... \\ \ldots & \ldots & \ldots & \ldots \end{array}

For $k\ge 11$ the search was not exhaustive.