challenges/e3/e3.hs

5 lines
174 B
Haskell
Raw Normal View History

2011-10-21 21:18:31 +00:00
factor n divisor
| (divisor == n-1 || n == 1) = [n]
| rem n divisor == 0 = (factor (fromIntegral n/divisor) 2) ++ (factor divisor 2)
| otherwise = factor n (divisor+1)