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

I.e., is there a sequence of primes whose decimal expansions have the following form:

$$a_1,\ a_1a_2,\ a_1a_2a_3,\ a_1a_2a_3a_4, \dots$$

What about with the order of the digits reversed, so each number's decimal representation is a final segment of the next one's? (Or any other interesting variation of restrictions?)

What about in other bases?

In binary, neither is possible. Starting with $2 = 10_2$, adding digits to the left would give even numbers greater than 2, hence composite. Adding to the right eventually hits 95. More generally it's clear that you'd have to add a $1$ digit, meaning that the sequence is of the form $x_{n+1} = 2x_n + 1$ with $x_0 = 10_2 = 2$. This has the general form $3\cdot 2^n - 1$. Since 2, 3, and 5 are primes, this expression will be congruent to $0\pmod 5$ every $5$ terms.

share|cite|improve this question
up vote 3 down vote accepted

The longest such sequences (of the first kind) end in 23399339, 29399999, 37337999, 59393339 or 73939133. The longest sequence of the second kind (not allowing prepending zeroes) ends in 357686312646216567629137.

(These numbers were found by a quick search using PARI/GP)

For base $b$ instead of $10$ observe the following:

Call $p$ a $b$-Gupta prime of the first kind if $p$ is prime and $\lfloor \frac pb\rfloor$ is zero or a $b$-Gupta prime of the first kind. Call $p$ a $b$-Gupta prime of the second kind if $p$ is prime and $b^k\le p<b^{k+1}$ and $k=0$ or the remainder $p\bmod b^k$ is a $b$-Gupta prime of the second kind.

If there are $r_k$ $b$-Gupta primes of some kind with $k$ digits, there are only $br_k$ numbers $p$ such that $\lfloor \frac pb\rfloor$ or $p\bmod b^k$ is a $b$-Gupta prime of the same kind. Heuristically, these candidates are prime with probability $\frac1{\ln p}\approx \frac1k\cdot \frac1{\ln b}$. Therefore we expect $r_{k+1}\lesssim\frac 1k\cdot \frac b{\ln b} r_k$, i.e. $r_k$ should fall off quite rapidly after a few initial steps.

share|cite|improve this answer
This is discussed at and other places you can find using the search term "truncatable primes". – Gerry Myerson Dec 31 '12 at 23:24
Oh, I should have googled the result 357686...137 I found :) – Hagen von Eitzen Jan 1 '13 at 17:39

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.