# HG changeset patch # User IBBoard # Date 1560801043 -3600 # Node ID 6f650dd96685c958dea3117a39979c6826a789c4 # Parent 075ff4e4feaf5c8b5ef24bfbad86ff8792ebf936 Minor tweak to prime efficiency diff -r 075ff4e4feaf -r 6f650dd96685 7-Haskell/day2.hs --- a/7-Haskell/day2.hs Mon Jun 17 20:26:30 2019 +0100 +++ b/7-Haskell/day2.hs Mon Jun 17 20:50:43 2019 +0100 @@ -54,4 +54,5 @@ -- Wilson's theorem seems easiest: https://en.wikipedia.org/wiki/Wilson%27s_theorem primes :: [Integer] - primes = [x | x <- [2 ..], (mod ((product [1 .. x-1]) + 1) x) == 0] \ No newline at end of file + -- Primes after 2 have to be odd (or else they're a multiple of 2!), so increment up the odd numbers + primes = 2 : [x | x <- [3, 5 ..], (mod ((product [1 .. x-1]) + 1) x) == 0] \ No newline at end of file