move prime funcs to module
parent
254727b0a8
commit
f4223215b1
|
@ -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))
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue