OFFSET
1,1
COMMENTS
The least terms with respectively 2, 3, 4 distinct digits are 19, 257, 24889.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..108 (all terms with <= 52 digits)
David A. Corneth, PARI program
EXAMPLE
19 is a term, because the digits of 19 are in nondecreasing order and 91 is the unique number != 19 given by a permutation of 19 and 91 = 7 * 13 is composite and the digits of 91 are not in nondecreasing order.
PROG
(PARI) is(k)=my(u=digits(k), n=#u); if(#vecsort(u, , 8)==1||u!=vecsort(u)||!isprime(k), return(0)); forperm(n, p, my(vp=Vec(p), v=[]); for(i=1, n, v=concat(v, u[vp[i]])); q=fromdigits(v); if(k!=q&&isprime(q), return(0))); 1
(PARI) \\ See PARI link
(Python)
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations as mp
from itertools import count, islice, combinations_with_replacement as mc
def bgen(d): yield from ("".join(m) for m in mc("123456789", d))
def agen(): yield from (t for d in count(1) for k in bgen(d) if len(set(k))!=1 and isprime(t:=int(k)) if not any((j:="".join(m))!=k and isprime(int(j)) for m in mp(k)))
print(list(islice(agen(), 44))) # Michael S. Branicky, Dec 23 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Jean-Marc Rebert, Dec 23 2023
STATUS
approved