[Question]
  [
This question will be a twist on finding the `n`th prime number.
# Challenge
You must write a program that will take one input `n`, and output the `n`th prime number whose decimal representation contains the decimal representation of `n` as a subtring.
Confused? Here are some examples.
```
n=1
Primes: 2, 3, 5, 7, 11
                    ^1 first prime that contains a 1
Output: 11
n=2
Primes: 2, 3, 5, 7, 11, 13, 17, 19, 23
        ^1                          ^2 second prime that contains a 2
Output: 23
n=3
Primes: 2, 3, 5, 7, 11, 13, 17, 19, 23
           ^1           ^2          ^3 third prime that contains a 3
Output: 23
n=10
Primes: 2, 3, 5, 7, 11, ..., 97, 101, 103, 107, 109, ..., 997, 1009, 1013, 1019, 1021, 1031, 1033
                                 ^1   ^2   ^3   ^4             ^5    ^6    ^7    ^8    ^9    ^10 tenth prime that contains a 10
Output: 1033
```
---
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so lowest byte count wins.
If something is confusing, please leave a comment.
  
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 8 bytes
Code:
```
¬µN¬π√•Np*¬Ω
```
Explanation:
```
¬µ          # Run this until the counting variable has reached the input value.
 N¬π√•       # Check if the input number is in the range variable.
    Np     # Check if the range variable is prime.
      *    # Multiply those two numbers (which is basically an AND operator).
       ¬Ω   # If true, increment the counting variable.
           # After the loop, the stack is empty and implicitly prints N.
```
Uses **CP-1252** encoding. [Try it online!](http://05ab1e.tryitonline.net/#code=wrVOwrnDpU5wKsK9&input=MTA).
[Answer]
# Pyth - 11 bytes
```
e.f&P_Z}`Q`
```
[Test Suite](http://pyth.herokuapp.com/?code=e.f%26P_Z%7D%60Q%60&test_suite=1&test_suite_input=1%0A2%0A3%0A10&debug=0).
[Answer]
# Python 2, ~~67~~ ~~65~~ 62 bytes
```
f=lambda n,k=0,m=2,p=1:k/n or-~f(n,k+p%m*(`n`in`m`),m+1,p*m*m)
```
Test it on [Ideone](http://ideone.com/epHD9u).
### How it works
We use a corollary of [Wilson's theorem](https://en.wikipedia.org/wiki/Wilson%27s_theorem):
![corollary of Wilson's theorem](https://i.stack.imgur.com/mPJHD.png)
At all times, the variable **p** is equal to the square of the factorial of **m - 1**.
If **k < n**, `k/n` will yield **0** and **f** is called recursively. **m** is incremented, **p** is updated, and **k** is incremented if and only if **m** is a prime that contains **n**.
The latter is achieved by adding the result of `p%m*(`n`in`m`)` to **k**. By the corollary of Wilson's theorem if **m** is prime, `p%m` returns **1**, and if not, it returns **0**.
Once **k** reaches **n**, we found **q**, the **n**th prime that contains **n**.
We're in the next call during the check, so **m = q + 1**. `k/n` will return **1**, and the bitwise operators `-~` will increment that number once for every function call. Since it takes **q - 1** calls to **f** to increment **m** from **2** to **q + 1**, the outmost call to **f** will return **1 + q - 1 = q**, as intended.
[Answer]
## Bash, 27 bytes
```
primes 0|grep $1|sed $1q\;d
```
`primes` comes from bsdgames.
Takes input as a command line argument, and outputs on STDOUT.
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 13 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
√ó√ÜP,¬≥D≈ì·π£/·πñ¬µ#·π™
```
[Try it online!](http://jelly.tryitonline.net/#code=w5fDhlAswrNExZPhuaMv4bmWwrUj4bmq&input=&args=MTA)
[Answer]
# Mathematica, 75 bytes
```
Nest[NestWhile[b=NextPrime,b@#,!StringContainsQ@@ToString/@{#,a}&]&,1,a=#]&
```
May still be golfable.
[Answer]
# Java, 194 180 173 ~~171~~ 112 Bytes
Code:
```
a->{int i=1,j,n,r=0;for(j=n=new Integer(a);(r+=++i>=j&(""+j).contains(""+n)?1:0)!=n;j+=j%i==0?i=1:0);return j;}
```
Ungolfed:
```
class P{
    static int i=1,j,n,r;
    public static void main(String[]s) {
        for(
                j=n=new Integer(s[0]); //executes once before first iteration
                (r+=++i>=j&(""+j).contains(""+n)?1:0)!=n; //executes on first and every iteration
                j+=j%i==0?i=1:0 //executes after first and every iteration
           ) {
            ;
        }
        System.out.print(j);
    }
}
```
[Answer]
## Ruby, ~~62~~ 61 bytes
```
->i{Prime.lazy.map(&:to_s).grep(/#{i}/).first(i)[-1]}
```
Requires the `-rprime` flag (+8 bytes).
```
->i{            # lambda with one argument
Prime           # iterator over all primes
.lazy           # make the iterator lazy (can't evaluate infinite primes)
.map(&:x.to_s)  # convert the primes to strings
.grep(/#{i}/)   # find primes that regex match on the input (contain it)
.first(i)       # take the first (input) primes that satisfy this
[-1]            # take the last of those
}
```
[Answer]
# Julia, ~~61~~ 60 bytes
```
f(n,k=0,m=1)=k<n&&f(n,k+isprime(m)contains("$m","$n"),m+1)+1
```
[Try it online!](http://julia.tryitonline.net/#code=ZihuLGs9MCxtPTEpPWs8biYmZihuLGsraXNwcmltZShtKWNvbnRhaW5zKCIkbSIsIiRuIiksbSsxKSsxCgpmb3IgbiBpbiAxOjIwCiAgICBAcHJpbnRmKCIlMmQgJTRkXG4iLCBuLCBmKG4pKQplbmQ&input=)
[Answer]
# [MATL](http://github.com/lmendo/MATL), 18 bytes
```
`@YqVGVXf?3M]NG<]&
```
[**Try it online!**](http://matl.tryitonline.net/#code=YEBZcVZHVlhmPzNNXU5HPF0m&input=MTA)
### Explanation
This generates primes in order using a `do...while` loop. For each prime, the condition is tested (and the prime is consumed). If satisfied, that prime is pushed to the stack again. The number of elements in the stack is used as count of how many qualifying primes we have found. When there are enough of them, the last one is displayed.
```
`         % Do...while
  @       %   Push iteration index, k. Starts at 1
  YqV     %   k-th prime. Convert to string
  GV      %   Push input, n. Convert to string
  Xf      %   Find string within another
  ?       %   If non-empty
    3M    %     Push k-th prime again (increase stack size by 1)
  ]       %   End if
  NG<     %   Is stack size less than input number? If so proceeed with
          %   a new iteration; else exit do...while loop
]         % End do...while
&         % Implicitly display only top number in the stack 
```
[Answer]
## Pyke, 15 bytes
```
Q.fD_P.I`Q`R{(e
```
[Try it here!](http://pyke.catbus.co.uk/?code=Q.fD_P.I%60Q%60R%7B%28e&input=3)
[Answer]
# Bash + GNU coreutils, 66 Bytes
In contrast to @Doorknob's solution, this one only needs things that are installed on every GNU/Linux:
```
for((n=2;;n++)){
[ `factor $n|wc -w` -eq 2 ]&&grep $1<<<$n&&exit
}
```
[Answer]
# [Perl 6](http://perl6.org), 41 bytes
```
->$n {grep({.is-prime&&/$n/},2..*)[$n-1]}
```
### Explanation:
```
-> $n { # has one parameter
  grep(
    {
      .is-prime # check that it is prime
      &&        # and
      / $n /    # that it contains the argument in the "string"
    },
    2 .. *      # for all numbers starting with 2
  )[ $n - 1 ]   # only take the $n-th one
                # ( accounting for 0 based array access )
}
```
### Test:
```
#! /usr/bin/env perl6
use v6.c;
use Test;
my &prefix:<‚Ñôùïü> = ->$n {grep({.is-prime&&/$n/},2..*)[$n-1]}
my @test = (
  1  => 11,
  2  => 23,
  3  => 23,
  10 => 1033,
);
plan +@test;
for @test {
  is ‚Ñôùïü.key, .value, .gist
}
```
```
1..4
ok 1 - 1 => 11
ok 2 - 2 => 23
ok 3 - 3 => 23
ok 4 - 10 => 1033
```
[Answer]
# Java 8, ~~192~~ ~~183~~ ~~181~~ 171 bytes (full program)
```
interface M{static void main(String[]a){long n=new Long(a[0]),c=0,r=1,m,i;for(;c<n;c+=m>1&(r+"").contains(a[0])?1:0)for(m=++r,i=2;i<m;m=m%i++<1?0:m);System.out.print(r);}}
```
[Try it online.](https://tio.run/##JY7LDsIgFAV/hTTRQMAGXJaiP6Arl00XhD5yqxcMRY0x/XascXcWM5Mz2afdTd01Z/Cpj4N1PTl/5mQTOPIM0BG04OklRfBj01r2uQU/Em98/yKndVLbyJYJZ6SIRgkUoIcQqXa1144bPKgtjbwoWOmCT2tr/htHVUn2I9FwHgWYvYYaNRrcAOe1OsoKmb6859RjGR6pvK8PEo1ML0vOWckv)
**Explanation:**
```
interface M{                    // Class
  static void main(String[]a){  //  Mandatory main-method
    long n=new Long(a[0]),      //   Input argument as number
         c=0,                   //   Counter, starting at 0
         r=1,                   //   Result-number, starting at 1
         m,i;                   //   Temp number
    for(;c<n;                   //   Loop as long as `c` does not equals `n`
        c+=                     //     After every iteration: increase `c` by:
           m>1                  //      If the current `r` is a prime,
           &(r+"").contains(a[0])?
                                //      and this prime contains the input `n`
            1                   //       Increase `c` by 1
           :                    //      Else:
            0)                  //       Leave `c` the same
      for(m=++r,                //    Increase `r` by 1 first with `++r`, and set `m` to it
          i=2;i<m;              //    Inner loop `i` in the range [2, `m`)
        m=m%i++<1?              //     If `m` is divisible by `i`
           0                    //      Change `m` to 0 (so it's not a prime)
          :                     //     Else:
           m);                  //      Leave `m` unchanged
    System.out.print(r);}}      //    Print `r` as result
```
---
# Java 8, 105 bytes (lambda function)
```
n->{int c=0,r=1,m,i;for(;c<n;c+=m>1&(r+"").contains(n+"")?1:0)for(m=++r,i=2;i<m;m=m%i++<1?0:m);return r;}
```
[Try it online.](https://tio.run/##hVBNi8IwEL37KwbBJSG1NO7NafQXrBePyx6ysUq0mUqSCov0t3eT6lW8DLwP5r2Zs77p5flwGU2rQ4Avbek@A7AUG3/UpoFdhhMBhuVJHBMzzNIIUUdrYAcECkZabu6TTVWFV7JwhcVj5xmamtAI5Tbyg3kxn/PSdBRTUmCU4VauK56dTgnhC6tWaGuHTrmFFaKW22rtOPom9p7A4zBiDr/2v20Kf3a4dfYALu1k@@gtnb5/QPNH9f1fiI0ruz6W1yTFlhiVhkk@HfJSX73RP9/osuLPTw3jPw)
Same as above, but with `n` as integer input and without the verbose class stuff.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-h`](https://codegolf.meta.stackexchange.com/a/14339/), ~~15~~ ~~13~~ 11 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
_j ¬©Zs√®U}jU
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWg&code=X2ogqVpz6FV9alU&input=OA)
[Answer]
# [Husk](https://github.com/barbuz/Husk), 10 bytes
```
!fo`‚Ç¨d¬πdƒ∞p
```
[Try it online!](https://tio.run/##yygtzv7/XzEtP@FR05qUQztTjmwo@P//v6EBAA "Husk ‚Äì Try It Online")
## Explanation
```
!fo`‚Ç¨d¬πdƒ∞p
 fo     ƒ∞p filter the infinite list of primes by the following:
     d¬π    are the digits of n
   `‚Ç¨      a sublist of('`' switches the arguments)
       d   the digits of the number?
!          get nth element
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), ~~14~~ 13 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
√©√¢^^Œµ√Æ√Ø5~8<IM
```
[Run and debug it](https://staxlang.xyz/#p=82835e5eee8c8b357e383c494d&i=1%0A2%0A3%0A10&m=2)
A good question for a generator.
-1 byte from recursive.
## Explanation
```
Z{|p_$yI^*}{gnH input: single number, n
             n  generator mode: count(stops after n values are found)
Z               push a 0 under the input(start value)
 {        }     filter block:
  |p            number is prime?
         *      and
    _$          string representation of number
      yI^       contains n?
           {g   generator block:
                implicit increment to get next number
              H get last generated value
```
[Answer]
# [Haskell](https://www.haskell.org/), 97 bytes
```
import Data.List
p n=[z|z<-[2..],all((>0).mod z)[2..z-1],show n`elem`subsequences(show z)]!!(n-1)
```
[Try it online!](https://tio.run/##HclLCsIwEADQvaeY7hJoh8a1deWyniAEOupAg/nZpAjBu0d0@95K@cnOtWZ9iluBCxXC2eZySBAmXT/1NOgjounJOSHOo0QfH1DlD@ugTJ/X@IawsGO/5P2W@bVzuHMW/6jSdJ0Ig5LNkw0wgad0BZE2GwogJAlaIarRtC8 "Haskell ‚Äì Try It Online")
"subsequences" is an annoyingly long word.
Thanks to @xnor for saving a byte.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 8 bytes
```
‚Äπ√ûp'?c;i
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLigLnDnnAnP2M7aSIsIiIsIjEwIl0=)
[Answer]
## Clojure, 118 bytes
```
(defn s[n](nth(filter(fn[x](if(.contains(str x)(str n))(not-any? #(=(mod x %)0)(range 2 x))))(drop 2(range)))(dec n)))
```
Just gets the nth element of lazy infinite sequence of numbers which are prime and have `n` in their string representation. 
You can try it here : <https://ideone.com/ioBJjt>
[Answer]
## Actually, 16 bytes
```
;$‚ïó`P$‚ïú@√≠u`‚ïìdP.X
```
[Try it online!](http://actually.tryitonline.net/#code=OyTilZdgUCTilZxAw611YOKVk2RQLlg&input=MTA)
Explanation:
```
;$‚ïó`P$‚ïú@√≠u`‚ïìdP.X
;$‚ïó               make a copy of n, push str(n) to reg0
   `      `‚ïì      push the first n values where f(k) is truthy, starting with k=0:
    P$              kth prime, stringified
      ‚ïú@√≠u          1-based index of n, 0 if not found
            d     remove last element of list and push it to the stack (dequeue)
             P    nth prime
              .   print
               X  discard rest of list
```
[Answer]
## PowerShell v2+, ~~108~~ 99 bytes
Ooof. The lack of any sort of built-in prime calculation/checking really hurts here.
```
param($n)for(){for(;'1'*++$i-match'^(?!(..+)\1+$)..'){if("$i"-like"*$n*"){if(++$o-eq$n){$i;exit}}}}
```
Takes input `$n`, enters an infinite `for()` loop. Each iteration, we use a `for` loop wrapped around the [PowerShell regex prime checker](https://codegolf.stackexchange.com/a/57636/42963) (h/t to Martin) to turn it into a prime generator by incrementing `$i` each time through the loop. (For example, running just `for(){for(;'1'*++$i-match'^(?!(..+)\1+$)..'){$i}}` will output `2, 3, 5, 7...` separated by newlines).
Then a simple `-like` check to see if `$n` is somewhere in `$i`, and increment our counter `$o`. If we've reached where `$n` and `$o` are equal, output `$i` and `exit`. Otherwise we continue through the `for` to find the next prime and the process repeats.
[Answer]
# APL(NARS), 39 chars, 78 bytes
```
{s‚Üê‚çïw‚Üê‚çµ‚ãÑ2{(w‚â§‚çµ)‚àßk‚Üê‚à®/s‚ç∑‚çï‚ç∫:‚ç∫‚ãÑ(1œÄ‚ç∫)‚àá‚çµ+k}1}
```
1œÄ is the next prime number...; test:
```
  f‚Üê{s‚Üê‚çïw‚Üê‚çµ‚ãÑ2{(w‚â§‚çµ)‚àßk‚Üê‚à®/s‚ç∑‚çï‚ç∫:‚ç∫‚ãÑ(1œÄ‚ç∫)‚àá‚çµ+k}1}
  f¬®1 2 3 10
11 23 23 1033 
```
but that already at 20 goes out the stack space...
Instead this below seems ok even if has lenght a little more long (61 chars)
```
‚àár‚Üêf w;i;k;s
r‚Üê2‚ãÑs‚Üê‚çïw‚ãÑi‚Üê1
‚Üí0√ó‚ç≥(w‚â§i)‚àßk‚Üê‚à®/s‚ç∑‚çïr‚ãÑr‚Üê1œÄr‚ãÑi+‚Üêk‚ãÑ‚Üí2
‚àá
  f¬®1 2 3 10 20 100
11 23 23 1033 4201 100999 
```
[Answer]
# [Add++](https://github.com/cairdcoinheringaahing/AddPlusPlus), 36 bytes
```
L,5*2^R√ü√ûPABDBJVB]dG‚Ç¨Œ©ez√ü¬£*BZB]A1_$:
```
[Try it online!](https://tio.run/##S0xJKSj4/99Hx1TLKC7o8PzD8wIcnVycvMKcYlPcHzWtObcyterw/EOLtZyinGIdDeNVrP5XWBkbcLlW6HBxquQk5ialJCoY2mUCeSkgwv8/AA "Add++ ‚Äì Try It Online")
Fairly inefficient. Iterates over each integer \$i\$ such that \$i \le 25x^2\$ and filters out composites and primes that don't contain \$n\$. Finally, we take the \$n\$th value of the remaining integers.
]