primes = 2 : filter isPrime [3..] isPrime 1 = False isPrime x = check primes where check (p:ps) | p*p > x = True | x `mod` p == 0 = False | otherwise = check ps main = print $ length $ takeWhile (<100000) primes