%I #44 Jul 05 2024 10:07:38
%S 2,3,5,7,11,12,14,16,20,21,23,25,29,30,32,34,38,41,43,47,49,50,52,56,
%T 58,61,65,67,70,74,76,83,85,89,92,94,98,101,102,104,106,110,111,113,
%U 115,119,120,122,124,128,131,133,137,139,140,142,146,148,151,155,157,160,164,166,173,175,179,182
%N Numbers whose sum of digits is a prime.
%H Christian N. K. Anderson, <a href="/A028834/b028834.txt">Table of n, a(n) for n = 1..25000</a> (terms 1..1000 from T. D. Noe)
%H Christian N. K. Anderson, <a href="/A028834/a028834.png">Ulam Spiral</a> for a(n) <= 100000.
%e 89 included because 8+9 = 17, which is prime.
%p a:=proc(n) local nn: nn:=convert(n,base,10): if isprime(sum(nn[j],j=1..nops(nn)))=true then n else fi end: seq(a(n),n=1..200); # _Emeric Deutsch_, Mar 17 2007
%t Select[Range[200],PrimeQ[Total[IntegerDigits[#]]]&] (* _Harvey P. Dale_, Feb 18 2011 *)
%o (Haskell)
%o a028834 n = a028834_list !! (n-1)
%o a028834_list = filter ((== 1) . a010051 . a007953) [1..]
%o -- _Reinhard Zumkeller_, Nov 13 2011
%o (Sage) [x for x in range(200) if (sum(Integer(x).digits(base=10))) in Primes()] # _Bruno Berselli_, May 05 2014
%o (PARI) is(n)=isprime(sumdigits(n)) \\ _Felix Fröhlich_, Aug 16 2014
%o (Python)
%o from sympy import isprime
%o def ok(n): return isprime(sum(map(int, str(n))))
%o print(list(filter(ok, range(183)))) # _Michael S. Branicky_, Jun 18 2021
%o (R) require(gmp); which(sapply(1:1000, function(i) isprime(sum(floor(i/10^(0:(nchar(i)-1)))%%10)))==2) # _Christian N. K. Anderson_, Apr 22 2024
%Y Cf. A007953, A028835, A028842, A052018, A052019, A052020, A052021, A052022.
%Y Cf. A010051; A046704 is a subsequence.
%Y Complement of A104211.
%K nonn,base,easy,nice
%O 1,1
%A Armand Turpel (armand(AT)vo.lu, armand_t(AT)geocities.com)
%E More terms from Scott Lindhurst (ScottL(AT)alumni.princeton.edu)