Solved 5 with Haskell.
Optimized primeFactors.