Additive Primes amongst first x Primes
Pyke, 9 7 bytes
~p>#Yss
Try it online!
The single byte is_prime
was only pushed 3 hours ago. Github commit.
~p - All the prime numbers
> - first input of them
#Yss - filter(^)
Y - digits(^)
s - sum(^)
s - is_prime(^)
Python 2, 124 118 bytes
With help from Riker:
n,f,P=input(),filter,lambda n:all(n%i for i in range(2,n))
f(lambda x:P(sum(map(int,`x`)))&P(x),f(P,range(2,n*n))[:n])
Original:
n,o,c,P=input(),0,2,lambda n:all(n%i for i in range(2,n))
while o<n:
o+=P(c)
if P(sum(map(int,`c`)))and P(c):print c
c+=1
Checking primality in Python ain't fun.
Röda, 136 135 bytes
f n{P=[2]S=[2]seq 3,863|{|i|{P|{P+=i;s=0;((""..i)/"")|parseInteger _|s+=_;S+=i if[s in P and not(i in S)]}if{|p|[i%p>0]}_}if[#P<n]}_;S}
Try it online!
It's a function that returns the requested additive primes.
Usage: main { f(25) | print ap for ap }
The code uses version 0.12, which is in branch roda-0.12
.
Ungolfed:
function f(n) {
primes := [2]
ultraprimes := [2]
seq(3, 863) | for i do
break if [ #primes = n ]
if [ i%p != 0 ] for p in primes do
primes += i
sum := 0
((""..i)/"") | parseInteger _ | sum += digit for digit
ultraprimes += i if [ sum in primes and not (i in ultraprimes) ]
done
done
ultraprimes
}