Im trying do some work on Project Euler for fun, but I got stuck now on an problem and want to move on but cant seem to get my function working. Im trying to get count the primefactors of a given integer. The function works on smaller numbers such as 13195:
> primeFactor 13195
[29,13,7,5]
But when I run a bigger number such as 600851475143:
> primeFactor 601851475143
[]
This seems really weird to me. I know haskell is a lazy language, but I don´t think it should be that lazy...
primeFactor' :: Int -> [Int]
primeFactor' n = [ p | p <- primes' [] [2 .. n], n `mod` p == 0 ]
where primes' :: [Int] -> [Int] -> [Int]
primes' ys [] = ys
primes' ys (x:xs) | x `notMultipleOf` ys = primes' (x:ys) xs
| otherwise = primes' ys xs
-- helper function to primeFactor'
notMultipleOf :: Int -> [Int] -> Bool
notMultipleOf n [] = True
notMultipleOf n xs = and [n `mod` x /= 0 | x <- xs]