login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Least number whose set of decimal digits coincides with the set of decimal digits of prime(n).
1

%I #93 Sep 13 2022 09:33:26

%S 2,3,5,7,1,13,17,19,23,29,13,37,14,34,47,35,59,16,67,17,37,79,38,89,

%T 79,10,103,107,109,13,127,13,137,139,149,15,157,136,167,137,179,18,19,

%U 139,179,19,12,23,27,29,23,239,124,125,257,236,269,127,27,128,238,239

%N Least number whose set of decimal digits coincides with the set of decimal digits of prime(n).

%e prime(5) = 11 and 1 have the same set of digits {1}, and 1 is the smallest such number, hence a(5) = 1.

%p f:= proc(p) local L,i;

%p L:= sort(convert(convert(convert(p,base,10),set),list));

%p if L[1] = 0 then L[1]:= L[2]; L[2]:= 0 fi;

%p add(L[-i]*10^(i-1),i=1..nops(L)) end proc:

%p seq(f(ithprime(i)),i=1..100); # _Robert Israel_, Sep 12 2022

%t 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 *)

%o (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)

%o (Python)

%o from sympy import prime

%o def a(n):

%o s = "".join(sorted(set(str(prime(n)))))

%o return int(s) if "0" not in s else int(s[1] + "0" + s[2:])

%o print([a(n) for n in range(1, 63)]) # _Michael S. Branicky_, Sep 12 2022

%Y Cf. A179239, A179308.

%K nonn,base

%O 1,1

%A _Jean-Marc Rebert_, Sep 12 2022