login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Primes whose sum of decimal digits has the same set of decimal digits as the prime.
1

%I #27 Mar 06 2023 02:59:40

%S 2,3,5,7,199,919,991,2999,9929,11177,11717,17117,31333,33331,71171,

%T 71711,161611,616111,999499,1111333,1131133,1131331,1133131,1313311,

%U 3111313,3111331,3131113,3131311,3133111,3311131,3337777,3377377,3773377,3773773,7377373,7733377,7737337,7737733,32333333

%N Primes whose sum of decimal digits has the same set of decimal digits as the prime.

%H Robert Israel, <a href="/A360986/b360986.txt">Table of n, a(n) for n = 1..10000</a>

%e a(5) = 199 is a term because 199 is prime and 1+9+9 = 19 has the same set {1,9} of decimal digits as 199.

%p dmax:= 7: # for terms with up to dmax digits

%p dsets:= proc(s, S) option remember;

%p # nondecreasing lists [x_1, ..., x_n] with sum s and set of elements S

%p local i, x1;

%p if S = {} then if s = 0 then return {[]} else return {} fi fi;

%p x1:= min(S);

%p `union`(seq(map(t -> [x1$i, op(t)], procname(s-i*x1, S minus {x1})), i=1..`if`(x1=0,dmax,floor(s/x1))))

%p end proc:

%p R:= {2,3,5,7}: count:= 4:

%p for s from 2 to 9*dmax-1 do

%p if s mod 3 = 0 then next fi;

%p ds:= convert(convert(s,base,10),set);

%p DS:= select (t -> nops(t) > 1 and nops(t) <= dmax, dsets(s,ds));

%p for r in DS do

%p for v in remove(t -> member(t[1],[0,2,4,5,6,8]) or t[-1]=0,combinat:-permute(r)) do

%p p:= add(v[i]*10^(i-1),i=1..nops(v));

%p if isprime(p) then R:= R union {p}; count:= count+1;

%p fi

%p od od od:

%p sort(convert(R,list));

%o (PARI) isok(p) = if (isprime(p), my(d=digits(p)); Set(d) == Set(digits(vecsum(d)))); \\ _Michel Marcus_, Feb 28 2023

%Y Cf. A000040, A158473.

%Y Primes in A249515.

%K nonn,base

%O 1,1

%A _Robert Israel_, Feb 27 2023