f :: Integer -> [Integer]
factorsOf = f (head primes) (tail primes) where
  f n ns m
    | m < 2          = []
    | m < n^2        = [m]
    | m `mod` n == 0 = n : f n ns (m `div` n)
    | otherwise      = f (head ns) (tail ns) m

primes
factorsOf :: Integer -> [Integer]
factorsOf = f (head primes) (tail primes) where
  f n ns m
    | m < 2          = []
    | m < n^2        = [m]
    | m `mod` n == 0 = n : f n ns (m `div` n)
    | otherwise      = f (head ns) (tail ns) m
factorsOf = f (head primes) (tail primes) where
  f n ns m
    | m < 2          = []
    | m < n^2        = [m]
    | m `mod` n == 0 = n : f n ns (m `div` n)
    | otherwise      = f (head ns) (tail ns) m