Is $4\underbrace{999 . . . 9}_{224 ({\rm times})}$ prime

number theoryprime numbers

Is $4\underbrace{999 . . . 9}_{224 ({\rm times})}$ prime?

I wanted to find smallest prime its sum of digits is $2020$. I started with small primes; the smallest three digits prime its sum of digits is 22 is $499$; four digits is $4999$ with sum of digits 31, five digit is $49999$ with sum of 40.For the sum $2020$ we have:

$2020=224\times 9+4$ and desired number can be of the form $4\underbrace{999 . . . 9}_{224 ({\rm times})}$ . So this number has at least 225 digits. If it is not prime we have to search for numbers with number of digits more than 225 which of course have digits less than 9 and first digit probably less than 4. I could not check it with my computer. I have these questions:

1- is $4\underbrace{999 . . . 9}_{224 ({\rm times})}$ primes?

2- are numbers of the form $499 . . . 99$ always primes? If so what is theoretical reason? If not what is conditions for it to be prime?

Update: the closed form of these numbers is $N=5\times 10^n-1=5(10^n-1)+ 4$, $n ≥ 2$ if n is even we have:

$10^{2k}-1=(10^k-1)(10^k+1)$

Since $[10^n-1, 5, 4]=1$ N can be a prime, but brute force gives a counter result. If n is odd N can be composite.

Best Answer

Answering the implicit question: what is the smallest prime with digit sum $2020$?

$\color{blue}{5}999999999999999999999999$
$9999999999999999999999999$
$999999999\color{blue}{8}999999999999999$
$9999999999999999999999999$
$9999999999999999999999999$
$9999999999999999999999999$
$9999999999999999999999999$
$9999999999999999999999999$
$9999999999999999999999999$ is prime.

Alternative form: $10^{225}-4\cdot10^{224}-10^{165}-1$

This is a single decimal number of $225$ digits written across $9$ lines of $25$ digits each. All digits are $9$ except for the initial $5$ and a single $8$ in the third line, so its digit sum is: $$225\cdot9-5=2020.$$

This is the highest placement of the $8$ that yields a prime number, so this is the smallest prime number with digit sum $2020$.


Edit: to explain the methodology in response to comments.

$224\cdot9<2020$ so we know that we need at least $225$ digits. We can start from $10^{225}-1$, which is $225$ nines, and we need to reduce the total digit sum by exactly $5$, reducing leading digits in preference to later digits and checking whether each number is prime.

The first number to check is $\color{blue}{4}999999\dots\;$ but we know this is not prime.

Next, check
$\color{blue}{58}99999\dots$
$\color{blue}{5}9\color{blue}{8}9999\dots$
$\color{blue}{5}99\color{blue}{8}999\dots$
$\color{blue}{5}999\color{blue}{8}99\dots$

and so on. Then, if needed, check
$\color{blue}{67}99999\dots$
$\color{blue}{688}9999\dots$
$\color{blue}{68}9\color{blue}{8}999\dots$
$\color{blue}{68}99\color{blue}{8}99\dots$

It turns out that the first prime found is the number given above. The number is equivalent to reducing the digit representing $10^{224}$ by $4$ and the digit representing $10^{165}$ by $1$. This gives us the alternative form of the number.

Related Question