module Divisors where divisors :: Integer -> [Integer] divisors n = filter ((0 ==) . mod n) [1..n]
- module Divisors where
- divisors :: Integer -> [Integer]
divisors n = 1:n:(divisorsAux 2)wheredivisorsAux k| (fromIntegral k) > sqrt (fromIntegral n) = []| otherwise = if n `mod` k == 0then if n`div`k ==kthen k:(divisorsAux (k+1))else k:(n`div`k):(divisorsAux (k+1))else divisorsAux (k+1)- divisors n = filter ((0 ==) . mod n) [1..n]