# 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?

-
When it is only divisible by itself and one. Boooyaa – CogitoErgoCogitoSum Feb 12 '13 at 1:52
@CogitoErgoCogitoSum: This is an answer to the title only. Now answer the main question! Find all $n$s! – user59671 Feb 12 '13 at 1:53
@CutieKrait I did answer the question - the header question at the very least - so dont fault me. It was a joke - lighten up. Its not like I posted a formal answer below; I only posted a comment. – CogitoErgoCogitoSum Feb 12 '13 at 2:02
For the $n$ in OEIS A004023, minus $1$. As far as I know it is not known whether there are infinitely many. Also see Wikipedia. The $-1$ is because CutieKrait wrote down $(10^{n+1}-1)/9$ above, but OEIS chose to use $(10^n-1)/9$. Therefore the OEIS sequence starts with $2$. – David Moews Feb 12 '13 at 2:04
oeis.org/A004022 as well – Will Jagy Feb 12 '13 at 2:14

## 2 Answers

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)$.

-