Primes are everywhere...
they hide inside Pi
3.1415926535897932384626433832795028841971693993751
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.Shortest answer in bytes wins!