# For which positive integers n does there exist a prime whose digits sum to n?

Motivated by this earlier question, I thought of this problem:

Question: For which positive integers $n$ does there exist a prime whose decimal digits sum to $n$?

We can make two "easy" observations:

• $1$ is not the sum of the digits of a prime.
• $6,9,12,\ldots$ cannot be the sum of the digits of a prime (by the mod 3 version of Casting Out Nines). However, $3$ is the sum of the digits of $3$.

This makes me suspect that everything else is possible. Using the GAP code below, I checked that everything possible is achieved for $n \leq 71$ (although, this is not a particularly impressive feat).

Comment: I'm aware that questions along the lines of can the primes do that? can often be hard to answer (such as Goldbach's Conjecture), but hopefully some non-trivial contribution can be made to this question, possibly along the lines of "it is true assuming Conjecture X", or possibly via an algorithm for computing these primes faster.

GAP code:

DecimalDigitSum:=function(n)
if(n<10) then return n; fi;
return (n mod 10)+DecimalDigitSum(Int(n/10));
end;;

A:=List([1..1000],i->0);;
n:=1;;
while(true) do
n:=NextPrimeInt(n);
s:=DecimalDigitSum(n);
if(A[s]=0) then
Print(s," is the sum of digits of the prime ",n,"\n");
A[s]:=n;
fi;
od;


The output was:

2 is the sum of digits of the prime 2
3 is the sum of digits of the prime 3
5 is the sum of digits of the prime 5
7 is the sum of digits of the prime 7
4 is the sum of digits of the prime 13
8 is the sum of digits of the prime 17
10 is the sum of digits of the prime 19
11 is the sum of digits of the prime 29
14 is the sum of digits of the prime 59
13 is the sum of digits of the prime 67
16 is the sum of digits of the prime 79
17 is the sum of digits of the prime 89
19 is the sum of digits of the prime 199
20 is the sum of digits of the prime 389
22 is the sum of digits of the prime 499
23 is the sum of digits of the prime 599
25 is the sum of digits of the prime 997
26 is the sum of digits of the prime 1889
28 is the sum of digits of the prime 1999
29 is the sum of digits of the prime 2999
31 is the sum of digits of the prime 4999
32 is the sum of digits of the prime 6899
35 is the sum of digits of the prime 8999
34 is the sum of digits of the prime 17989
37 is the sum of digits of the prime 29989
38 is the sum of digits of the prime 39989
40 is the sum of digits of the prime 49999
41 is the sum of digits of the prime 59999
43 is the sum of digits of the prime 79999
44 is the sum of digits of the prime 98999
46 is the sum of digits of the prime 199999
47 is the sum of digits of the prime 389999
49 is the sum of digits of the prime 598999
50 is the sum of digits of the prime 599999
52 is the sum of digits of the prime 799999
53 is the sum of digits of the prime 989999
55 is the sum of digits of the prime 2998999
56 is the sum of digits of the prime 2999999
58 is the sum of digits of the prime 4999999
59 is the sum of digits of the prime 6999899
61 is the sum of digits of the prime 8989999
62 is the sum of digits of the prime 9899999
64 is the sum of digits of the prime 19999999
65 is the sum of digits of the prime 29999999
67 is the sum of digits of the prime 59899999
68 is the sum of digits of the prime 59999999
71 is the sum of digits of the prime 89999999
70 is the sum of digits of the prime 189997999


The sequence on the right is Sloane's A067523 (or A067180 if 0's are placed in the gaps), which are not particularly enlightening. The sequence on the left does not seem to be in Sloane's OEIS.

-
Another question that comes to my mind is: Is there any integer $n$ which is the digit sum of infinitely many distinct primes? For example if $n=2$ were to have this property, it would imply an infinitude of generalized Fermat primes of the form $10^{2^m}+1$ which goes against usual conjectures on such primes. – Jeppe Stig Nielsen Aug 18 '15 at 19:16