move prime funcs to module

master
Evan Hemsley 2020-10-28 01:30:06 -07:00
parent 254727b0a8
commit f4223215b1
2 changed files with 7 additions and 5 deletions

View File

@ -1,9 +1,5 @@
module Main where
primes = 2 : [i | i <- [3..],
and [rem i p > 0 | p <- takeWhile (\p -> p^2 <= i) primes]]
primeFactors n = filter (\a -> mod n a == 0) (takeWhile (\m -> m * m < n) primes)
import Prime
main = do
print (last (primeFactors 600851475143))

6
haskell/prime.hs Normal file
View File

@ -0,0 +1,6 @@
module Prime where
primes = 2 : [i | i <- [3..],
and [rem i p > 0 | p <- takeWhile (\p -> p^2 <= i) primes]]
primeFactors n = filter (\a -> mod n a == 0) (takeWhile (\m -> m * m < n) primes)