Recently, I've been thinking about primes which ending digits are the digits of its index among the primes. The first one I came up with is 17, the 7th prime -> 1(7).

The first obvious generalization is extending this to bases other than 10. This is the list of the first 20 primes with the bases in which they are index primes (n - index, p - prime, b - base):

Code:

n - p - b
1 - 2 - xxx
2 - 3 - xxx
3 - 5 - xxx
4 - 7 - xxx
5 - 11 - 6
6 - 13 - 7
7 - 17 - 10
8 - 19 - 11
9 - 23 - 14
10 - 29 - 19
11 - 31 - 20
12 - 37 - 5, 25
13 - 41 - 14, 28
14 - 43 - 29
15 - 47 - 2, 4, 16, 32
16 - 53 - 37
17 - 59 - 21, 42
18 - 61 - 43
19 - 67 - 24, 48
20 - 71 - 51

There is a simple condition that determines whether a prime p with index n is an index prime in the base b:

d = floor(log_b(n)) + 1

p is an index prime in base b iff p - n = 0 (mod b ^ d)

or in other words, if the prime p and its index n have the same remainder modulo the smallest power of b strictly greater than n, then p is an index prime in base b. However, this condition is nothing else than formally saying that the ending digits are the same.

One trivial property is that every prime greater than 7 is an index prime in some base b. This is guaranteed by the fact that in the base b = p - n, the "digits" of p are 1 followed by n, which obviously ends with n. This also trivially holds for all factors of (p - n) that are greater than n.

It gets a bit complicated for the bases less than or equal to n. There it depends on the powers of prime factors of (p-n).

Few open questions (possibly simple, but I haven't answered them yet):

1. Does there exist an index prime for every integer base b > 1?

2. Is there a finite or infinite number of index primes for any base (that has at least one index prime)?

3. What is the portion of primes that are index primes in more than one base?

One other property is:

For primes p > 7, the base (p - n) is the greatest one for which p is an index prime.

Proof:

The form of p in base b = p - n is 1 * b^1 + n * b^0. For bases greater than (p - n), the last "digit" is less than n, thus the ends don't match. For bases b > p, the ends are the numbers themselves, and because p is always greater than its index, p can not be an index prime for such bases.

Other generalizations are for left index primes and middle index primes. Left index primes begin with their index, middle index primes contain it enclosed by at least one "digit" on both sides. The formal condition for left index primes is

d_n = floor(log_b(n)) + 1

d_p = floor(log_b(p)) + 1

p - n * b ^ (d_p - d_n) < b ^ (d_p - d_n)

The smallest example is 11, the 5th prime, in base 2 -> (101)1.

I will update this later with other examples of all three types and their other properties.

I will strongly appreciate help with the three open questions, in the context of right, left, and middle index primes - separately, but if there are some differences in the answers when treating the index primes as one big case where the index is somewhere in the prime's digits, i.e. not separating the left and right cases, then those are also welcome, possibly even more.

Viliam Furík