i have been curious about prime numbers lately and have been wondering what is the smallest prime number that is made of consecutive numbers as its digits.

example of number for further clarification: 1234567891011121314151617.........

i have checked till sequence till '16' number by bruteforce. currently facing problem for '17' numbers sequence. i just wanted to know if there exits a number in such above pattern that is actually a prime?? is it ever calculated by someone before. or is there any property/theorem that describes such numbers cannot be prime.

more clarification regd sequence

1234567891011 . .

Edit: I have written a python script with gmpy2 library to check for primes (based on answer). i have checked till 2000 but the program cannot find any. not sure if the program is working or not for very large numbers.

#code to print primes
import gmpy2

digit = 1
number = 1
while count:
    # print(count)
    if gmpy2.is_prime(number):
    while temp!= 0:
        temp //= 10

  • $\begingroup$ You have taken into account my remarks that I erase now that your text is well improved. $\endgroup$
    – Jean Marie
    Commented Sep 11, 2021 at 21:37
  • 4
    $\begingroup$ mathworld.wolfram.com/SmarandachePrime.html $\endgroup$
    – nickgard
    Commented Sep 11, 2021 at 23:37
  • $\begingroup$ @nickgard Good catch ! $\endgroup$
    – Jean Marie
    Commented Sep 12, 2021 at 10:10

2 Answers 2


Partial answer

Let $N(n)$ be some positive integer whose digits are the consecutive positive integers up to $n$.


$N(n)$ is composite for $n\neq 6k+1$ $k\in \mathbb N$


$N(2k)$ is divisible by $2$ because its last digit is even.

For $N(3k)$ is easy to verify that the sum of its digits is divisible by $3$, which implies that $N(3k)$ is divisible by $3$ (divisibility criteria). This in turn implies that the sum of digits of $N(3k-1)$ is also divisible by $3$ (otherwise, adding as digits the number $3k$ would result in a number $N(3k)$ not divisible by $3$).

Therefore, $N(n)$ is composite for $n\neq 6k+1$ $k\in \mathbb N$

  • $\begingroup$ Could you explain more completely why $N(3k-1)$ has to be divisible by $3$ ? $\endgroup$
    – coffeemath
    Commented Sep 14, 2021 at 5:29
  • $\begingroup$ $N(3k-1)$ is equal to $N(3k)$, whose sum of digits is divisible by $3$, less the digits of $3k$, whose sum of digits is divisible by $3$; thus, it follows that the sum of digits of $N(3k-1)$ is divisible by $3$, and thus $N(3k-1)$ is divisible by $3$. $\endgroup$ Commented Sep 14, 2021 at 10:18
  • $\begingroup$ That's clear, Juan-- Thanks and +1. $\endgroup$
    – coffeemath
    Commented Sep 14, 2021 at 10:23
  • $\begingroup$ You are welcome! ;-) $\endgroup$ Commented Sep 14, 2021 at 19:24

Unfortunately, no prime of the form $1\_2\_...\_n$ has been found yet. Furthermore, it has been conjectured that such a prime could not exist at all, since every candidate up to $1\_2\_...\_1000000$ has been already checked (Batalov, 2018). For details, see https://mathworld.wolfram.com/SmarandachePrime.html and also the YouTube video https://www.youtube.com/watch?v=vKlVNFOHJ9I.

Moreover, also truncated concatenations, known as Champernown primes, have already been checked up to very large terms and the smallest $7$ such primes are listed in the OEIS sequence $A176942$ (see https://oeis.org/A176942), while the eighth one should be above $1\_2\_...\_113821$ according to https://oeis.org/A071620


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .