1, 101, 10101, 1010101, 101010101, 10101010101, 1010101010101, 101010101010101, 10101010101010101, 1010101010101010101, 101010101010101010101, 10101010101010101010101, 1010101010101010101010101, 101010101010101010101010101, 10101010101010101010101010101

This is the sequence A094028 of the On-Line Encyclopedia of Integer Sequences (OEIS). According to a comment from Felix Fröhlich on the sequence’s page:

101 is the only term that is prime, since (100^k-1)/99 = (10^k+1)/11 * (10^k-1)/9. When k is odd and not 1, (10^k+1)/11 is an integer > 1 and thus (100^k-1)/99 is nonprime. When k is even and greater than 2, (100^k-1)/99 has the prime factor 101 and is nonprime.

Felix Fröhlich, Oct 17 20151

It isn’t particularly striking that it should be the case. Let’s see why 101 is the only prime number of the sequence.

The sequence

First of all, let’s study a bit more the sequence. Let’s call A(n) the (n1)th element of the sequence A(0) is the first element of the sequence).

For the first few elements we have:

A(0)=1 A(1)=101 A(2)=10101 A(3)=1010101

We can see that we can write the sequence as A(n)=k=0n100k.

For example, for the first element we have A(0)=1000=1.

Similarly, for n=2, A(2)=10000+100+1=10101.

A simpler form

For the (n1)th element of the sequence, we have:

A(n)=1+100+10000++100n1+100n

We would like to remove some of terms, let’s consider

100A(n)=100+10000+1000000++100n+100n+1

This sequence has many similar terms to A(n), let’s subtract 100A(n) from A(n).

We can cancel the common terms, we end up with:

A(n)100A(n)=1100n+1

To find out what A(n) is, let’s isolate it from the equation.

99A(n)=1100n+1 99A(n)=100n+11 A(n)=100n+1199

So, we have: A(n)=100n+1199, which we can see from the comment in the OEIS’s website.

Cleaning things a bit

We can rewrite A(n) as A(n)=(10n+1)2199, because 100=102.

We now have a difference of squares, we can factorize it further:

A(n)=(10n+1+1)(10n+11)99

To make it a bit simpler to work with, let’s do a little variable substitution with k=n1.

A(k)=A(n1)=(10(n1)+1+1)(10(n1)+11)99=(10n+1)(10n1)99

Therefore,

A(k)=(10n+1)(10n1)99

Okay, now we can write the (k1)th element of the sequence a bit more easily, but it isn’t clear how we could prove that only 101 is prime. Let’s try to simplify this expression a bit more.

A(k)=(10n+1)(10n1)99

First of all, we can see that (10n1) will be of the form 9999n-times.

We can split the 99 in the denominator into 911. We now have

A(k)=(10n+1)(9999n-times)911

We can do the same for the 9999n-times in the numerator, we get:

A(k)=(10n+1)(91111n-times)911

We can cancel out the 9s.

A(k)=(10n+1)(1111n-times)11

Division by 11

Let’s take a small break from our sequence to discuss the divisibility by 11. For a number n to be divisible by 11, we must have that n0(mod11)

A number in decimal base can be expressed as n=akak1a1a0, so the value of n is 10kak+10k1ak1++10a1+a0.

Note that 101(mod11).

So, 10kak+10k1ak1++10a1+a0(1)kak+(1)k1ak1++(a1)+a0(mod11)

Since (1)2n=1nN, we deduce that every even placed digit are added, whereas odd placed numbers are subtracted ((1)2n+1=1nN).

So, we can rewrite

(1)kak+(1)k1ak1++(a1)+a0a0a1+a2a3+a4a5(mod11)

Since we want to check if n is divisible by 11, we must check if

a0a1+a2a3+a4a50(mod11)

So, n is divisible by 11 if the sum of even placed digit (starting from the rightmost position) minus the sum of the odd placed digit is divisible by 11.

The proof

A(k)=(10n+1)(1111n-times)11

Now that we know that when a number is divisible by 11, let’s analyse A(k).

n>1 is even

First, let’s suppose that n is even. In that case, we get that 1111n-times is divisible by 11, because, since there is as much even placed 1s as odd placed 1s, the sum of even placed digit minus the sum of the odd placed digit is 0, which is divisible by 11.

Now, let’s use the variable k=n1 to link the divisibility of 1111n-times by 11 with the sequence. We notice that for n>1 to be even, we must have that k is odd, because k=n1.

For k3, we have n=k+14, so that 1111(n4)-times>11.

Thus, we can deduce that 1111(n4)-times11>1 and that it is an integer.

Posing a=1111(n4)-times11, we get A(k)=(10n+1)a.

Since A(k) is the result of the multiplication between two integers, each not equal to one, A(k) is not prime.

n>1 is odd

We can use a similar trick for any even k2, this time with the other part of A(k). When k is even (so that n is odd) in (10n+1), we have that one 1 is at a even position and the other at an odd position, thus 11=0 which is divisible by 11. Similarly, we have that (10n+1)>11 because n3. Thus, (10n+1)11>1 and it is an integer. We can then conclude that A(k) is not prime for even k=n12.

The remaining cases

This leaves us with two cases, k=0 and k=1. A(0)=1 is not prime by definition and A(1) is prime. Since for any other k, A(k) is not prime, then A(1) is the only prime in the sequence.

References

  1. OEIS. Sequence A094028, https://oeis.org/A094028