Mercurial > repos > other > SevenLanguagesInSevenWeeks
diff 7-Haskell/day2.hs @ 91:075ff4e4feaf
Fix the prime checking
Greatest common denominator MAY work, but it's probably inefficient
(I also wondered whether it wouldn't always work, but then the
number can't be a prime!)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 17 Jun 2019 20:26:30 +0100 |
parents | c27c87cd0f08 |
children | 6f650dd96685 |
line wrap: on
line diff
--- a/7-Haskell/day2.hs Sun Jun 16 21:09:33 2019 +0100 +++ b/7-Haskell/day2.hs Mon Jun 17 20:26:30 2019 +0100 @@ -54,4 +54,4 @@ -- Wilson's theorem seems easiest: https://en.wikipedia.org/wiki/Wilson%27s_theorem primes :: [Integer] - primes = [x | x <- [2 ..], (gcd ((product [1 .. x-1]) + 1) x) == x] \ No newline at end of file + primes = [x | x <- [2 ..], (mod ((product [1 .. x-1]) + 1) x) == 0] \ No newline at end of file