A271628 Primes that are the sum of the digits of the numbers from 1 to n, for some n.
3, 73, 109, 127, 433, 1009, 1117, 1801, 2017, 2089, 2143, 2467, 2503, 2791, 3079, 3331, 3583, 4159, 4519, 4663, 4951, 5437, 5581, 5923, 6121, 6301, 6553, 7039, 7561, 8353, 8623, 8821, 9001, 9199, 9631, 9811, 10837, 11719, 12637, 13177, 13249, 13627, 14401, 15391
Offset: 1
Examples
The sum of the digits of 1 and 2 is a prime: 1 + 2 = 3. The sum of the digits of the number from 1 to 16 is a prime: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 0 + 1 + 1 + 1 + 2 + 1 + 3 + 1 + 4 + 1 + 5 + 1 + 6 = 73.
Links
- Paolo P. Lava, Table of n, a(n) for n = 1..10000
Programs
-
Maple
with(numtheory): P:=proc(q) local a,b,c,k,n; a:=0; for n from 0 to q do b:=0; c:=n; for k from 1 to ilog10(n)+1 do b:=b+(c mod 10); c:=trunc(c/10); od; a:=a+b; if isprime(a) then print(a); fi; od; end: P(10^6);
-
Mathematica
Select[Accumulate@ Map[Total@ IntegerDigits@ # &, Range[0, 1200]], PrimeQ] (* Michael De Vlieger, Apr 11 2016 *)
-
PARI
lista(nn) = for (n=1, nn, if (isprime(p=sum(k=1, n, sumdigits(k))), print1(p, ", "))); \\ Michel Marcus, Apr 11 2016