When is the number 11111…1 a prime number?

For which $n$ is the sum:
$$\sum_{k=0}^{n}10^k$$
a prime number? Are they finite?

Solutions Collecting From Web of "When is the number 11111…1 a prime number?"

After adding $1$, the $n$s for which the sum above is known to be prime or probably prime are given in the OEIS sequence A004023. (The $+1$ is because the OEIS lists numbers $n$ such that $(10^n-1)/9$ is prime, but the sum in the question is instead equal to $(10^{n+1}-1)/9$.) Also, see the Wikipedia article and the Prime Pages entry.

These primes are called “repunit primes” since their decimal expansion consists of a repeated series of $1$s. The repunits corresponding to
$$n=1, 18, 22, 316, \text{and } 1030$$
$$\text{ (using the n in the questioner’s formula above)}$$
are known to be prime. The repunits corresponding to
$$n=49080, 86452, 109296, \text{and } 270342$$
$$\text{ (again using the n in the questioner’s formula above)}$$
are as far as I know only known to be probably prime.

The obvious factorization
$$\frac{10^{km}-1}{9}=\frac{10^k-1}{9}(1+10^k+\cdots+10^{k(m-1)})$$
means that, for $(10^{n+1}-1)/9$ to be prime, $n+1$ must also be prime.

There are conjectured to be infinitely many repunit primes.

Partial solution:

Given a prime $p \neq 2, 5$, let $n = Q(p – 1) + R$. We use Fermat’s Little Theorem modulo $p$:

\begin{align} \sum_{k = 0}^n10^k &= 1 + \sum_{i = 1}^Q10^{(i – 1)(p – 1)}(10^1 + 10^2 + \dotsb + 10^{p – 1}) + 10^{Q(p – 1)}(10^1 + 10^2 + \dotsb + 10^R)\\ &\equiv 1 + \sum_{i = 1}^Q\frac{p(p – 1)}{2} + (10^1 + 10^2 + \dotsb + 10^R)\\ &\equiv \sum_{k = 0}^R10^k \pmod{p}. \end{align}

The $p(p – 1)/2$ came from the fact that the residues of $10^1, 10^2, \dotsc, 10^{p – 1}$ modulo $p$ form a permutation of $1, 2, \dotsc, (p – 1)$.

Numbers having the shape n = 1111......1 have less probability to be a prime.

If sum of all digits are divisible by 3 then that number is divisible by 3. Using this rule If number of digits of n is divisible by 3 then n is surely not a prime. $\therefore 111,111111,111111111, ….$ are divisible by 3

If number of digits are divisible by 2 (even number of digits in n), then n can be partitions into multiple 11s. e.g. 1111 can be partitioned as 11 11. Which is divisible by 11 $\therefore 11,1111,111111, ….$ are divisible by 11.

So if number of digits are not divisible by 2 or 3 (e.g. $5,7,11,13,17,19,23,25,29,31,35,37,….$) we are not obvious that the number is not prime. However for these numbers we get large prime divisors most of the time. Like 11111 = 41*271