login
Prime numbers k where the d(j)-th digit is j for d(j) and j > 0 and d(j) = 0 if and only if j is not a digit of k and d(m) is the m-th digit of k reading from the left.
2

%I #81 Oct 02 2021 19:40:16

%S 103,2143,4001,4201,4231,12503,21503,50341,52301,53201,106453,106543,

%T 146203,426103,600401,600451,603401,603541,620051,620401,623401,

%U 1000507,1004567,1004657,1005467,1006547,1030067,1034567,1035467,1043657,1050307,1050367,1056347,1070063

%N Prime numbers k where the d(j)-th digit is j for d(j) and j > 0 and d(j) = 0 if and only if j is not a digit of k and d(m) is the m-th digit of k reading from the left.

%C Sequence consists of the primes in which, for each j in 1..N (where N is the number of digits), j is the j-th digit, or is the k-th digit where k is the j-th digit, or is 0.

%C Equivalently, terms are primes that can be obtained from the number 1234..N (where N is the number of digits) by swapping the positions of zero or more pairs of digits and replacing zero or more unswapped digits with 0's. (Leading zeros are not allowed, so the '1' cannot be replaced with a 0.)

%C The maximum number of digits N is 9.

%C The last term is 987400321.

%C Some terms were found by _Claudio Meller_.

%C This sequence has 1404 terms. - _David A. Corneth_, Sep 26 2021

%H Michael S. Branicky, <a href="/A346499/b346499.txt">Table of n, a(n) for n = 1..1404</a>

%H Michael S. Branicky, <a href="/A346499/a346499_1.txt">Python program for complete sequence</a>

%e 103 is a term because it is a prime number, 1 is the 1st digit, 3 is the 3rd digit, and there is no digit 2, so the 2nd digit is 0.

%e 1 2 3

%e | . |

%e | . |

%e 1 0 3

%e 2143 is a term because it is a prime number, 1 and 2 are the 2nd and 1st digits, respectively, and 3 and 4 are the 4th and 3rd digits, respectively.

%e 1 2 3 4

%e \ / \ /

%e X X

%e / \ / \

%e 2 1 4 3

%e 146203 is a term because it is a prime number, 1 is the 1st digit, 2 and 4 are the 4th and 2nd digits, respectively, 3 and 6 are the 6th and 3rd digits, respectively, and there is no digit 5, so the 5th digit is a 0:

%e 1 2 3 4 5 6

%e | \ \ / . /

%e | \ X__ __/

%e | \ / \ /.

%e | X X .

%e | / \ __/ \__

%e | / X . \

%e | / / \ . \

%e 1 4 6 2 0 3

%e .

%e 1 2 3 4 5 6 digit positions

%e digit = 1 4 6 2 0 3

%e ^-------^ 2,4 swapped

%e ^-----------^ 3,6 swapped

%e .

%e 1 2 3 4 5 6 digit positions

%e digit = 1 4 6 2 0 3

%e ^-----^ 2,4 swapped

%e ^--------^ 3,6 swapped

%t q[n_] := Module[{d = IntegerDigits[n], nd}, nd = Length[d]; AllTrue[Range[nd], d[[#]] == 0 || (d[[#]] <= nd && d[[d[[#]]]] == # ) &]]; Select[Range[1070063], PrimeQ[#] && q[#] &] (* _Amiram Eldar_, Sep 26 2021 *)

%o (PARI) is(n) = { if(!isprime(n), return(0)); my(d = digits(n), f = vector(10), s); for(i = 1, #d, f[d[i]+1]++; if(f[d[i]+1] > 1 && d[i]!=0, return(0))); for(i = 1, #d, if(d[i] == 0 && f[i+1]>0, return(0) ); if(f[d[i]+1] > 0 && #d < d[i], return(0)); if(d[i] > 0 && d[d[i]] != i, return(0)); ); 1 } \\ _David A. Corneth_, Sep 26 2021

%o (Python) # see link for faster version for generating entire sequence

%o from sympy import isprime

%o def ok(n):

%o if n%10 not in {1, 3, 7, 9}: return False

%o digs = str(n)

%o if int(max(digs)) != len(digs): return False

%o for j, dj in enumerate(digs, start=1):

%o if dj != '0' and digs[int(dj)-1] != str(j): return False

%o return isprime(n)

%o print(list(filter(ok, range(1070064)))) # _Michael S. Branicky_, Sep 26 2021

%Y Primes in A348056.

%Y Cf. A000085.

%K nonn,base,fini

%O 1,1

%A _Rodolfo Kurchan_, Sep 25 2021

%E More terms from and new name from _David A. Corneth_, Sep 26 2021