By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10001st prime number?
— By listing the first six prime numbers:
— 2, 3, 5, 7, 11, and 13, we can see that
— the 6th prime is 13.
— What is the 10001st prime number?
SELECT number FROM
(SELECT row_number() OVER (ORDER BY number) as primeindex, number
WHERE isprime = 1) Primes
WHERE Primes.primeindex = 10001
On the surface this solution might seem pretty ‘meh’, but I’m a big fan. It’s obviously going to be my fastest solution because it’s a simple look up – very common in real life scenarios. I also got to use row_number() and a subquery as a data source which always delight me.