Collecting the output

1
2
3
4
5
6
factors :: (Integral a) => a -> [a] -> [a]
-- Pass a list of prime numbers to me :)
factors 1 _ = []
factors a (x:xs)
        | a `mod` x /= 0 = factors a xs
        | otherwise = (a `div` x) : (factors (a `div` x) (x:xs))