login
Numbers n such that n^d_1 + n^d_2 + ... n^d_k is prime where d_i is the i-th digit in the decimal representation of n.
3

%I #20 Apr 02 2023 13:42:15

%S 10,20,203,230,308,309,330,350,503,603,650,960,1068,1110,1206,1350,

%T 1404,1480,1730,1802,1860,1910,2032,2038,2044,2054,2250,2320,2502,

%U 3044,3082,3402,3970,4032,4046,4072,4120,4340,4450,4540,4650,4908,5204,5310,5402

%N Numbers n such that n^d_1 + n^d_2 + ... n^d_k is prime where d_i is the i-th digit in the decimal representation of n.

%C The number must contain a 0 in its decimal representation. If not, the number is divisible by n.

%H Giovanni Resta, <a href="/A239237/b239237.txt">Table of n, a(n) for n = 1..10000</a>

%e 20^2 + 20^0 = 401 is prime so 20 is a member of this sequence.

%e 308^3 + 308^0 + 308^8 = 80985213602898040129 is prime so 308 is a member of this sequence.

%p q:= n-> isprime(add(n^i, i=convert(n, base, 10))):

%p select(q, [$1..6000])[]; # _Alois P. Heinz_, Apr 02 2023

%t Select[Range[5000], PrimeQ@ Total[#^IntegerDigits[#]] &] (* _Giovanni Resta_, Mar 13 2014 *)

%o (Python)

%o import sympy

%o from sympy import isprime

%o def PowOpp(x):

%o ..if str(x).find('0') > -1:

%o ....num = 0

%o ....for i in str(x):

%o ......num += x**int(i)

%o ....if isprime(num):

%o ......return True

%o x = 1

%o while x < 10**4:

%o ..if PowOpp(x):

%o ....print(x)

%o ..x += 1

%o (Python)

%o from itertools import count, islice

%o from sympy import isprime

%o def A239237_gen(startvalue=1): # generator of terms >= startvalue

%o return filter(lambda n:'0' in (s:=str(n)) and isprime(sum(s.count(d)*n**int(d) for d in set(s))),count(max(1,startvalue)))

%o A239237_list = list(islice(A239237_gen(),20)) # _Chai Wah Wu_, Apr 02 2023

%Y Cf. A239236.

%Y Subsequence of A011540.

%K nonn,base

%O 1,1

%A _Derek Orr_, Mar 13 2014