# Number of primes below $x$, such that the digitsum is also prime

I counted the number of primes, such that the digit sum is also prime with the following PARI/GP-program and compared it with the number of primes below the powers of $10$ upto $10^9$

? for(k=1,9,x=0;y=0;for(j=1,10^k,if(isprime(j)==1,y=y+1;if(isprime(sumdigits(j))
==1,x=x+1)));print(k,"  ",x,"  ",y))
1  4  4
2  14  25
3  89  168
4  590  1229
5  3883  9592
6  30123  78498
7  246982  664579
8  2163899  5761455
9  18661619  50847534


I do not know, if there is a name for the number of primes below $x$, such that the digitsum is also prime, so I call the function $u(x)$.

• What is known about the asymptotic behaviour of $u(x)$. In particular, does the limit $$\lim_{x\rightarrow \infty} \frac{u(x)}{\pi(x)}$$ , where $\pi(x)$ is the prime counting function, exist ?
• We would expect that limit to be $0$, that is, the prime-digit-sum primes should have relative density $0$ inside the primes (although I doubt this has been proved). Indeed, the average digit sum of a prime near $x$ is about $4.5(\log x)/\log 10$, and the probability of a random integer that size being prime is about $1/\log\log x$ or so. So we expect that $u(x) \sim \pi(x)/\log\log x$. (We might need to multiply by some constant, reflecting local conditions: the digit sum will never be a multiple of $3$, for example.) – Greg Martin Sep 12 '15 at 16:15
• Interesting question! As a total aside, for(k=1,9,x=0;forprime(p=1,10^k,if(isprime(sumdigits(p)),x++));print(k," ",x," "primepi(10^k))) runs much faster (Pari 2.6+). – DanaJ Sep 12 '15 at 16:34

If $j$ has $m$ digits in base $b$, then the size of $sumdigits(j)$ is about $mb/2$, so the probability that $sumdigits(j)$ is prime is about $1/\ln(mb/2)$.
Since there are about $\frac{b^m}{m\ln(b)}$ primes with $m$ digits, there should be about $\frac{b^m}{m\ln(b)\ln(mb/2)}$ primes with $m$ digits with sumdigits also prime.