[Question]
  [
## Definition of Additive Primes:
* Numbers which have exactly 2 divisors are called *Prime* numbers.
* Numbers which are prime and their sum of digits is also a prime number are called ***[Additive Primes](http://prime-numbers.wikia.com/wiki/Additive_Primes)***
---
## Task:
Given an integer `x`, compute all the additive primes amongst the first `x` prime numbers, with `2` being considered both the first prime and additive prime number. The numbers are represented in base 10.
## Rules:
* The output consists of all the additive primes amongst the first `x` primes
* `0 < x < 151`, for this challenge, for functionality purposes
* Since the additive primes are all integers, decimals are not allowed (e.g.: you should output `2`, not `2.0`) and they must not be displayed as a fraction.
---
## Examples:
`10 -> 2 3 5 7 11 23 29`
**Explanation:**
The first 10 primes are `2 3 5 7 11 13 17 19 23 29`, and only `2 3 5 7 11 23 29` have their sum of digits prime numbers, those being, respectively `2,3,5,7,2,5,11`, so they are **additive primes**
Following the explanation from `example 1`, other test cases may be:
```
2 -> 2 3
25 -> 2 3 5 7 11 23 29 41 43 47 61 67 83 89
7 -> 2 3 5 7 11
```
---
## Leaderboard:
```
var QUESTION_ID=112088,OVERRIDE_USER=59487;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left;font-family:"Helvetica Neue"}table thead{font-weight:700;font-family:"Helvetica Neue"}table td{padding:5px;font-family:"Helvetica Neue"}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```
---
**NOTE:** Please read the newly-edited rule 1, it brings changes to the output format slightly
---
Your code should be as short as possible, since this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins. Good luck!
  
[Answer]
# [Röda](http://github.com/fergusq/roda), ~~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!](https://tio.run/nexus/roda#FYpRC8IgFEb/ysUIlMUaG0Vg9t6b4KMMGeTiPmQ29@b1ty8HH4fvwNlmCFkr249mR/I/GE6360CZkLKuaxTKpDrJOWNti@LMmKA4Lck/w@rffgFHqVFOmloCzjYBBtAwhReE78pxVyPGgnOmSBaP8dGNxVW3B30P9UpTts9Uswwz7y8CCOKCYQUHZfsD "Röda – TIO Nexus")
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
}
```
[Answer]
## Pyke, ~~9~~ 7 bytes
```
~p>#Yss
```
[Try it online!](https://tio.run/nexus/pyke#@19XYKccWVz8/7@hAQA "Pyke – TIO Nexus")
The single byte `is_prime` was only pushed 3 hours ago. [Github commit](https://github.com/muddyfish/PYKE/commit/aa38ccfb54780cdede75462b8e848c0068edf0fe).
```
~p      -    All the prime numbers
  >     -   first input of them
   #Yss -  filter(^)
    Y   -     digits(^)
     s  -    sum(^)
      s -   is_prime(^)
```
[Answer]
## 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.
[Answer]
# [Perl 6](https://perl6.org), 53 bytes
```
{grep *.comb.sum.is-prime,grep(*.is-prime,0..*)[^$_]}
```
[Try it](https://tio.run/nexus/perl6#VY7LToNAFIb38xT/wjQM0EEGCm1IjVvXuhM1LRwNCZcJMxibpr6YO18MB2pj3J3L93/nDJrwnogiY4OtHkibjDUHLIquJGzH41tPCq4oumYv9NCISi9VXzXkTwvH/euvhXD54/PVy9NptIJbY1UaW9RVS9rhYuaD/D7gotlNyUlpB6UX8O8vcdcanjFV71p452zGXrv@4lnewEFetWowPjz6UFQYKsFxZIA9l/ekh9rYe9PjzgxaH2D/K4lUfcCZ8HEJ@/icMXYa5eSXiBiTq98SK6QIQ8gIcoM4RBwhTpGESFKsI6w3jKX/2R8 "Perl 6 – TIO Nexus")
## Expanded:
```
{
  grep
    *.comb.sum.is-prime, # find the ultra primes from:
    grep(
      *.is-prime,        # find the primes
      0..*               # from all integers
    )[ ^$_ ]             # grab only the first x primes
}
```
If this challenge were changed so that you took the first *x* ultraprimes this could be shortened to just
```
{grep({($_&.comb.sum).is-prime},0..*)[^$_]}
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~96~~ 87 bytes
```
p=-input(),0;m=k=1
while sum(p):
 m*=k*k;k+=1;p+=m%k,
 if m%k*p[int(`k`,36)%35]:print k
```
*Thanks to @xnor for golfing off 9 bytes!*
[Try it online!](https://tio.run/nexus/python2#DchBCoAgEADAu6/Yi6BmkEQdkn1JBF6KZDOWUnq@eRumMvbx5pKVtoNPSOjEd8Zrh7ckxXoRkAySIU8dOs8dJklWQDygwfAa76wCBTvOWo7TtvDTBqhWNw0/ "Python 2 – TIO Nexus")
[Answer]
## Mathematica, ~~61~~ 47 bytes
```
Prime@Range@#~Select~PrimeQ@*Tr@*IntegerDigits&
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ÆNDS$€ĖÆPM
```
**[Try it online!](https://tio.run/nexus/jelly#@3@4zc8lWOVR05oj0w63Bfj@///fyBQA "Jelly – TIO Nexus")**
### How?
A slightly different approach...
```
ÆNDS$€ĖÆPM - Main link: n (>0)           e.g. 10
ÆN         - nth prime number                 29
     €     - for each in range(1,nth prime)   [1,    2,    3,   ..., 27,    28,     29]
    $      - last two links as a monad
  D        -     decimal digit list          [[1],  [2],  [3],  ...,[2,7], [2,8],  [2,9]]
   S       -     sum                          [1,    2,    3,   ..., 9,     10,     11]
      Ė    - enumerate                       [[1,1],[2,2],[3,3],...,[9,27],[10,28],[11,29]]
       ÆP  - is prime? (vectorises)          [[0,0],[1,1],[1,1],...,[0,1], [0,0],  [1,1]]
         M - indices of maximal elements     [       2,    3,   ...,                29]
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes
```
ÝØ¨vySOp—
```
Uses the **CP-1252** encoding. [Try it online!](https://tio.run/nexus/05ab1e#@3947uEZh1aUVQb7FzxqmPL/v5EpAA "05AB1E – TIO Nexus")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 11 bytes
```
ÆN€DS$ÆP$Ðf
```
[Try it online!](https://tio.run/nexus/jelly#@3@4ze9R0xqXYJXDbQEqhyek/f//38gUAA "Jelly – TIO Nexus")
Explanation:
```
ÆN€DS$ÆP$Ðf Main link (args: z)
ÆN€         Generate first z primes.
   DS$      Take the digital sum.
      ÆP    Check if it's prime.
        $   Join last two links and make a monad.
         Ðf Only keep elements which conform to the criterion above.
```
[**I got outgolfed.**](/a/112099/41024)
[Answer]
# MATL, ~~15~~ 13 bytes
*2 bytes saved thanks to @Luis*
```
:Yq"@V!UsZp?@
```
Try it at [**MATL Online**](https://matl.io/?code=%3AYq%22%40V%21UsZp%3F%40&inputs=10&version=19.8.0)
**Explanation**
```
        % Implicitly grab input as a number (N)
:       % Create an array [1...N]
Yq      % Get the k-th prime for each element k in that array
"       % For each element in this list
  @     % Get the current element
  V!U   % Break it into digits
  s     % Sum up the digits
  Zp    % Determine if this is a prime number
  ?@    % If it is, push the value to the stack
        % Implicit end of for loop and implicit display of the stack
```
[Answer]
# [Fig](https://github.com/Seggan/Fig), \$12\log\_{256}(96)\approx\$ 9.877 bytes
```
FtxFmC@p'pSf
```
[Try it online!](https://fig.fly.dev/#WyJGdHhGbUNAcCdwU2YiLCI3Il0=)
Explanation:
```
 t            # take the first
  x           # x items from
    mC        # all positive integers
   F          # filtered by
      @p      # is prime,
F       '     # then filter those by
          S   # the sum of
           f  # the digits
         p    # is prime
```
[Answer]
# [Bash](https://www.gnu.org/software/bash/) + coreutils, 97 bytes
```
p()(factor $1|wc -w)
for((;++n,c<$1;)){((`p $n`-2||(c++,`p $[n%10+n/10%10+n/100]`-2)))||echo $n;}
```
[Try it online!](https://tio.run/nexus/bash#@1@goamRlphckl@koGJYU56soFuuyZWWX6ShYa2tnaeTbKNiaK2pWa2hkVCgoJKXoGtUU6ORrK2tA@JG56kaGmjn6RsawGiDWKAKTU3NmprU5Ix8oAbr2v///xuZAgA "Bash – TIO Nexus")
[Answer]
# [Ohm](https://github.com/MiningPotatoes/Ohm), 10 bytes (CP437)
```
@▓_π;░_}Σp
```
This would be much shorter if I had vectorization or a component for the first N primes, but alas, I did not before this challenge (but I do [now](https://github.com/MiningPotatoes/Ohm/commit/56a37f4e8ac71400b5ccf5db0a5fd53a687d0c33)!).
Explanation:
```
@▓_π;░_}Σp    Main wire, arguments: a
@▓  ;         Map...over the range (1..n)
  _π            nth prime
     ░        Select from ToS where...
      _}Σ       The sum of all digits
         p      is prime
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 120 bytes
```
for($n=$args[0];$n){for(;'1'*++$i-notmatch($s='^(?!(..+)\1+$)..')){}if('1'*([char[]]"$i"-join'+'|iex)-match$s){$i};$n--}
```
[Try it online!](https://tio.run/nexus/powershell#HY1BCsIwEADfYlnYXUOCFTyV0ofECKFYu4IJJD0IMW@P1uswzLQlJoIwgk@PbE9ugMBlZwP2eFQKRIe4vfw2rwR5xBtNBzJG8bVXwMYgc6my0G6TnVefrHMdSKefUQIq/Mj9zfofgMwFpP4WWtfW2vnyBQ "PowerShell – TIO Nexus")
Prime checking in PowerShell sucks.
The outer `for` loop goes from input `$n` down to `0`. In the inner loop, we use a [prime generator](https://codegolf.stackexchange.com/a/57636/42963) on `$i`, then check `if` the digit-sum (`-join'+'|iex`) is also a prime. If so, we put `$i` on the pipeline. In either case, we decrement `$n--` and the outer `for` loop continues. The resulting `$i`s are gathered from the pipeline and an implicit `Write-Output` happens at program completion.
[Answer]
# Bash + GNU utilities + bsd-games package, 69
```
primes 2|sed -rn 'h;s/./ + &/g;s/.*/expr &|factor/e;/\w\s/!{x;p};'$1q
```
[Try it online](https://tio.run/nexus/bash#PY3LCoMwFET3fsVURKElvY0gXQT6JW4kXquLmjQ3UKH229MH1FkNZw7M4AIiS7SdMKYZNc7QJ9QNdKMNepfhE7ajQ15sorrkPy4coRS2Ifkw3VhQr8I9VJhRjUboSDigpOu37okXH1CuQ2ejC8SG2kcrtHsuxr9MVeh7@l9mvZs5vQE).
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 59 bytes
```
f(x)=[p|p<-vector(x,i,prime(i)),isprime(vecsum(digits(p)))]
```
[Try it online!](https://tio.run/##K0gsytRNL/j/P02jQtM2uqCmwEa3LDW5JL9Io0InU6egKDM3VSNTU1MnsxjCBkoWl@ZqpGSmZ5YUaxRoamrGgjQbGWgCAA "Pari/GP – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 5 bytes
```
ʁǎ'∑æ
```
[Try it online](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLKgceOJ+KIkcOmIiwiIiwiMTAiXQ==), or [verify more test cases](https://vyxal.pythonanywhere.com/#WyJBIiwiIiwiyoHHjifiiJHDpiIsIiIsIjJcbjI1XG43Il0=).
Explanation:
```
ʁ      # Range from 0 to n-1
 ǎ     # Nth prime (vectorising)
  '    # Filtered by:
   ∑   #   The digit sum
    æ  #   Is prime
```
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 9 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
♪╒g¶<gÅΣ¶
```
[Try it online.](https://tio.run/##ASYA2f9tYXRoZ29sZv//4pmq4pWSZ8K2PGfDhc6jwrb//zEwCjIKMjUKNw)
**Explanation:**
Since the input is guaranteed to be within the range \$[1,150]\$, where the \$150^{th}\$ prime is \$877\$, we'll use this to our advantage. (Although using `ó` (\$2^n\$ builtin using the implicit input) instead of `♪` would have worked as well, but would be way too slow for larger inputs.)
```
♪╒         # Push a list in the range [1,1000]
  g        # Filter it by:
   ¶       #  Check if the number is a prime
    <      # Then only keep the first (implicit) input amount of prime numbers
     g     # Filter it again,
      Å    # using 2 characters as inner code-block:
       Σ   #  Get the digit-sum of the current integer
        ¶  #  Check if it's also a prime
           # (after which the entire stack is output implicitly as result)
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
fȯṗΣd↑İp
```
[Try it online!](https://tio.run/##ARkA5v9odXNr//9myK/huZfOo2TihpHEsHD///8y "Husk – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 12 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
Èj}jU fÈìx j
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=yGp9alUgZsjseCBq&input=MTA)
[Answer]
# [Factor](https://factorcode.org/) + `math.primes math.unicode math.text.utils`, 47 bytes
```
[ nprimes [ 1 digit-groups Σ prime? ] filter ]
```
[Try it online!](https://tio.run/##LYxNCsIwFIT3nmIuYLAFEXThUty4EVeli5C@1tD8mbyAIp7G@3ilWLS7Gb75ppeKfSyX8/F02MJKvooQtaX0z0x3Fpm1mXt2WvmOkOiWyalpFiIxPybHMUaKjgx2iyeqFWrUa2zwKg3c/NmgQqcHzcsh@hwSPm/80B4tem2YItpiZUBiqUZRvg "Factor – Try It Online")
## Explanation:
It's a quotation (anonymous function) that takes an integer from the data stack as input and leaves a sequence of integers on the data stack as output.
* `nprimes` Obtain a list of the first n primes.
* `[ ... ] filter` Take elements from the list that match a predicate.
* `1 digit-groups` Obtain a list of digits from an integer.
* `Σ` Sum a sequence.
* `prime?` Is it prime?
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 6 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ÅpʒSOp
```
[Try it online](https://tio.run/##yy9OTMpM/f//cGvBqUnB/gX//xuZAgA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/w60FpyYF@xf8r9X5H21ooGOkY2SqYx4LAA).
**Explanation:**
```
Åp      # Get a list of the first (implicit) input amount of primes
  ʒ     # Filter this list by:
   S    #  Convert the prime to a list of digits
    O   #  Sum them together
     p  #  Check if this sum is a prime
        # (after which the filtered list is output implicitly as result)
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 13 bytes
```
:YqtFYA!XsZp)
```
Try it at [**MATL Online!**](https://matl.io/?code=%3AYqtFYA%21XsZp%29&inputs=25&version=19.8.0)
### Explanation
```
:      % Range [1 2 ... n], where n is implicit input
Yq     % Array of first n prime numbers
t      % Duplicate
FYA    % Convert to decimal digits. Gives a matrix, where each original 
       % number corresponds to a row. Left-pads with zeros if needed
!Xs    % Sum of rows
Zp     % Is prime? (element-wise)
)      % Use as logical index into the array of the first n prime numbers
       % Implicitly display
```
]