Skip to content

Instantly share code, notes, and snippets.

@Axect
Created February 17, 2018 20:06
Show Gist options
  • Save Axect/e9fe04864b7c080ae5dfa0c28d39a729 to your computer and use it in GitHub Desktop.
Save Axect/e9fe04864b7c080ae5dfa0c28d39a729 to your computer and use it in GitHub Desktop.
Lazy 2
primes' = 2 : [x | x <- [3..], isPrime' x]
isPrime' x = all (\p -> x `rem` p > 0) (factorsToTry x)
where
factorsToTry x = takeWhile (\p -> p*p <= x) primes'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment