[Question]
  [
# Primes are everywhere...
they hide inside Pi
3.141592653**58979**3238**462643**3832**795028841**971693993751
Let's get those primes!
# The Challenge
Given as input an integer `n>0`, find out how many primes are hidden inside the first `n` digits of `Pi`
# Examples
For `n=3` we should search for primes in `[3,1,4]`. There are 2 Primes `(3,31)`, so your code should output `2`  
For `n=10` , the first 10 digits are `[3,1,4,1,5,9,2,6,5,3]` and your code should output `12` because `[2, 3, 5, 31, 41, 53, 59, 653, 4159, 14159, 314159, 1592653]` were hidden (and found!)
# Test Cases
input -> output 
```
1->1  
3->2  
13->14  
22->28  
42->60  
50->93
150->197  
250->363  
500->895
```
# Rules
Your code must be able to **find all primes at least for `n=50`**  
Yes, you can **hardcode the first 50 digits** of `Pi` if you like  
**Entries hardcoding the answers are invalid** 
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'").Shortest answer in bytes wins!
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~10~~ 8 [bytes](https://github.com/Adriandmen/05AB1E/blob/master/docs/code-page.md)
-2 bytes thanks to Adnan (`p` vectorises)
```
<žsþŒÙpO
```
**[Try it online!](https://tio.run/##MzBNTDJM/f/f5ui@4sP7jk46PLPA//9/Q2MA "05AB1E – Try It Online")** (will work up to n=98413 but will be very slow even for n=50 due to the need to test such large numbers for primality - TIO times out at 60 seconds for n=50.)
### How?
```
<žsþŒÙpO - implicitly push input, n
<        - decrement = n-1
 žs      - pi to that many decimal places (i.e. to n digits)
   þ     - only the digits (get rid of the decimal point)
    Œ    - all sublists
     Ù   - unique values
      p  - is prime? (vectorises) 1 if so, 0 otherwise
       O - sum
         - implicitly print the top of the stack
```
[Answer]
# Mathematica, 76 bytes
```
Tr[1^Union@Select[FromDigits/@Subsequences@#&@@RealDigits[Pi,10,#],PrimeQ]]&
```
[Answer]
# Mathematica, ~~104~~ ~~97~~ 90 bytes
```
Length@DeleteDuplicates@Select[FromDigits/@Subsequences@First@RealDigits[Pi,10,#],PrimeQ]&
```
Hahahaha, I managed to make this work. I have no idea how to use Mathematica. XD
Input:
```
[50]
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~274~~ ~~237~~ ~~207~~ ~~194~~ 189 bytes
*-37 bytes thanks to Wheat Wizard! -14 bytes thanks to Mr.Xcoder.*
Hardcodes the first 50 digits of *pi* but manually computes everything else.
```
x=int(input());l="31415926535897932384626433832795028841971693993751"[:x]
print(sum(all(i%m for m in range(2,i))for i in{int(i)for w in range(x)for i in[l[j:j-~w]for j in range(x-w)]}-{1}))
```
[Try it online!](https://tio.run/##TY3LCoMwFET3/YogFBKoYHLzuha/RFy46COiUayiReyvp9VF2@WcOcx0z@HeeghhzpwfqPPdOFDGznUWAZdcodAKlEWDIMBKLbQEsCAMqkRYKzkarhEQwSge5elcHLp@W3qMDS3rmrpjQ65tTxriPOlLf7tQcXKMbcx92LLf7nH6KfO3z@u8Sqv4NRUbqf6UeGLFGi98ZSwEnrwB "Python 3 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~59~~ 32 bytes
*-27 bytes thanks to Erik the Outgolfer.*
```
“!⁶⁷¬,6½ạEC.wʠ€Ẉ!+Ẉfṭ¡’Ṿḣ³ẆVQÆPS
```
[Try it online!](https://tio.run/##AUoAtf9qZWxsef//4oCcIeKBtuKBt8KsLDbCveG6oUVDLnfKoOKCrOG6iCEr4bqIZuG5rcKh4oCZ4bm@4bijwrPhuoZWUcOGUFP///8xMA "Jelly – Try It Online")
## Explanation
```
“...’Ṿḣ³ẆVQÆPS
“...’           compressed string that evaluates to first 50 digits of pi (314159...)
     Ṿ          uneval; stringify
      ḣ³        first n characters of the string where n is the first command-line argument
        Ẇ       all sublists
         V      convert all elements to integers
          Q     deduplicate
           ÆP   convert all prime elements to 1 and others to 0
             S  sum
```
[Answer]
# R, ~~156~~ 123 bytes
```
cat(cumsum(c(1,1,0,1,1,4,1,0,0,3,0,0,2,7,3,1,0,3,0,0,0,0,0,0,4,1,0,6,0,3,2,0,0,0,0,0,0,4,3,3,6,0,4,8,2,5,3,6,0,5))[scan()])
```
Super interesting solution. Working on a proper one.
Saved 33 bytes thanks to @Giuseppe.
# R (+ numbers and gmp), 198 bytes
```
function(n,x=unique(gmp::as.bigz(unlist(sapply(1:n,function(x)substring(gsub("[.]","",numbers::dropletPi(50)),x,x:n))))))min(length(x),sum(sapply(sapply(x[x>0&!is.na(x)],gmp::factorize),length)==1))
```
Proper solution. Takes `n` as input.
Uses `numbers::dropletPi(50)` to generate the first 50 decimal places of pi. `gsub` removes the decimal point. `substring` takes every possible substring (surprise surprise) of pi up to `n`.
The returned list is flattened and converted to `gmp`'s `bigz` format. This format is required to store integers of length 50. `unique` takes the unique values of that vector. This result gets stored in `x`.
Then we check for primality. This is tricky, because there are a bunch of edge-cases and annoyances:
* For high `n`, there is a `0` in pi. This leads to substrings with a leading zero. `as.bigz` produces `NA`s with that, which have to be removed.
* On a similar note, the substring `"0"` will crash `gmp::factorize`, so has to be removed as well.
* For `n=1`, `x = 3`. Which in itself is ok, but the `bigz` representation of `3` is iterable, so `sapply` will get confused and report 16 primes. To this end we take the minimum of the length of the vector `x`, and the amount of primes in it.
* `gmp::isprime` can't seem to reliably handle the large numbers reliably. So instead we use `gmp::factorize` and check of the length of the output is 1.
So in all, we remove `0` and `NA` from `x`. We factorize all of `x` and check for the length. We count the number of occurrences of `1` and return the `min(occurences, length(x))`.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 9 bytes
```
#ṗumdQ↑İπ
```
[Try it online!](https://tio.run/##yygtzv7/X/nhzumluSmBj9omHtlwvuH///@GBgA "Husk – Try It Online")
Freezes beyond n=10 on tio. Reverse of the 05AB1E program.
]