Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: f949ca9410
Fetching contributors…

Cannot retrieve contributors at this time

19 lines (13 sloc) 0.409 kB
{-
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?
-}
module Main where
main = print $ nthPrime 10001
nthPrime 1 = 2
nthPrime n = head $ filter isPrime [(nthPrime (n-1) + 1)..]
isPrime n = not $ any (isFactor n) (takeWhile notTooBig [2..])
where
notTooBig m = m * m <= n
isFactor n m = n `rem` m == 0
Jump to Line
Something went wrong with that request. Please try again.