Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let $f_n$ be the number obtained by concatenating the first $n$ numbers (in base 10). For example

$f_1 = 1, f_3 = 123$ and $f_{13} = 12345678910111213.$

Now if $n$ is even or divisible by $5$ then so is $f_n$ and if $n(n+1) \equiv 0 \pmod{3}$ then $f_n$ is divisible by $3.$ My question is

Is $f_n$ always composite?

Verifying the question with a computer I get that it holds for $n$ up to $1000$ but I don't see how to prove it.

It does not seem to be case that $f_n$ always has small prime divisors as for example $f_7 = 127 \cdot 9721.$

Hence I don't see any simple approach to this question.

share|cite|improve this question
I don't think there is a good way. Concatenation of consecutive digits doesn't have a good simple mathematical description (try expressing it in symbols, instead of describing it with language) Note that you are left with the cases where $n \equiv 1 \pmod{6}$, and $f_7, f_{13}$ are not easily factorized. – Calvin Lin Apr 10 '14 at 14:42
@CalvinLin $\lfloor 10^n C_{10}\rfloor$, where C is Champernowne's constant... – draks ... Apr 10 '14 at 15:26
Heuristically, there should be a prime somewhere. $f_n \lt 2\cdot 10^n$, so using the fact that a "random" number $m$ has $\frac 1{\log m}$ chance of being prime, we can find the "expected" number of primes as being greater than $\sum \frac 1{\log (2\cdot 10^n)}$, which diverges. Even doing $\sum \frac 1{\log (2\cdot 10^{6n+1})}$ to take care of the even and divisible by $3$ cases it diverges. That doesn't help you find one, however. – Ross Millikan Apr 10 '14 at 15:34
I've completed testing to 53,000 without finding a prime, but as Charles says, we expect them eventually. – DanaJ Apr 17 '14 at 14:31
@DanaJ: You may consider submitting your calculations to the OEIS @ -- either now or when you hit the next 'natural' boundary. – Charles Apr 17 '14 at 17:49
up vote 7 down vote accepted

This concatenation is A007908 in the OEIS, where you can see that Charles Nicol and John Selfridge ask the same question in

R. K. Guy, Unsolved Problems in Number Theory, A3.

There are no primes in the first 5000 terms of the sequence, but heuristics suggest that there are infinitely many. In particular, there 'should' be about

$$\frac{\log\log n-\log\log m}{2}$$

primes between $m$ and $n$. This suggests that there should be about one prime with index between 5000 and

$$\exp(\exp(\log(\log 5000)+2))\approx2\cdot10^{27}$$

Edit: I have just checked the first 20,000 terms without finding a prime. This expands the previous interval to $6\cdot10^{31}$.

share|cite|improve this answer

As in the middle of November $2015$,there are no primes in the first $269293$ terms (!!), and it's very likely also that there are no primes in the first $300000$ terms. See the great Smarandache probable prime search managed by Serge Batalov. Update: As of 15 december 2015, there are no primes in the first $344869$ terms (the great Smarandache Prprime search).

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.