|
|
A346499
|
|
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
|
|
|
103, 2143, 4001, 4201, 4231, 12503, 21503, 50341, 52301, 53201, 106453, 106543, 146203, 426103, 600401, 600451, 603401, 603541, 620051, 620401, 623401, 1000507, 1004567, 1004657, 1005467, 1006547, 1030067, 1034567, 1035467, 1043657, 1050307, 1050367, 1056347, 1070063
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
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.
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.)
The maximum number of digits N is 9.
The last term is 987400321.
|
|
LINKS
|
|
|
EXAMPLE
|
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.
1 2 3
| . |
| . |
1 0 3
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.
1 2 3 4
\ / \ /
X X
/ \ / \
2 1 4 3
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:
1 2 3 4 5 6
| \ \ / . /
| \ X__ __/
| \ / \ /.
| X X .
| / \ __/ \__
| / X . \
| / / \ . \
1 4 6 2 0 3
.
1 2 3 4 5 6 digit positions
digit = 1 4 6 2 0 3
^-------^ 2,4 swapped
^-----------^ 3,6 swapped
.
1 2 3 4 5 6 digit positions
digit = 1 4 6 2 0 3
^-----^ 2,4 swapped
^--------^ 3,6 swapped
|
|
MATHEMATICA
|
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 *)
|
|
PROG
|
(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
(Python) # see link for faster version for generating entire sequence
from sympy import isprime
def ok(n):
if n%10 not in {1, 3, 7, 9}: return False
digs = str(n)
if int(max(digs)) != len(digs): return False
for j, dj in enumerate(digs, start=1):
if dj != '0' and digs[int(dj)-1] != str(j): return False
return isprime(n)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,fini
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|