A357096 Least number whose set of decimal digits coincides with the set of decimal digits of prime(n).
2, 3, 5, 7, 1, 13, 17, 19, 23, 29, 13, 37, 14, 34, 47, 35, 59, 16, 67, 17, 37, 79, 38, 89, 79, 10, 103, 107, 109, 13, 127, 13, 137, 139, 149, 15, 157, 136, 167, 137, 179, 18, 19, 139, 179, 19, 12, 23, 27, 29, 23, 239, 124, 125, 257, 236, 269, 127, 27, 128, 238, 239
Offset: 1
Examples
prime(5) = 11 and 1 have the same set of digits {1}, and 1 is the smallest such number, hence a(5) = 1.
Programs
-
Maple
f:= proc(p) local L,i; L:= sort(convert(convert(convert(p,base,10),set),list)); if L[1] = 0 then L[1]:= L[2]; L[2]:= 0 fi; add(L[-i]*10^(i-1),i=1..nops(L)) end proc: seq(f(ithprime(i)),i=1..100); # Robert Israel, Sep 12 2022
-
Mathematica
a[n_] := Module[{d = Union[IntegerDigits[Prime[n]]]}, If[d[[1]] == 0, d[[1;;2]] = d[[2;;1;;-1]]]; FromDigits[d]]; Array[a, 100] (* Amiram Eldar, Sep 13 2022 *)
-
PARI
a(n)=my(v=vecsort(digits(prime(n)),,8),w=v);if(v[1]==0,j=#v;w=if(j>2,v[3..j],[]);w=concat(Vecrev(v[1..2]),w));fromdigits(w)
-
Python
from sympy import prime def a(n): s = "".join(sorted(set(str(prime(n))))) return int(s) if "0" not in s else int(s[1] + "0" + s[2:]) print([a(n) for n in range(1, 63)]) # Michael S. Branicky, Sep 12 2022