2011-10-21 21:18:31 +00:00
|
|
|
factor n divisor
|
2011-10-22 16:44:33 +00:00
|
|
|
| (divisor >= n-1 || n == 1) = [n]
|
|
|
|
| rem n divisor == 0 = (factor (n `div` divisor) 2) ++ (factor divisor 2)
|
2011-10-21 21:18:31 +00:00
|
|
|
| otherwise = factor n (divisor+1)
|
2011-10-22 16:44:33 +00:00
|
|
|
|
|
|
|
mymax [] acc = acc
|
|
|
|
mymax (x:xs) acc
|
|
|
|
| x > acc = mymax xs x
|
|
|
|
| otherwise = mymax xs acc
|
|
|
|
|
|
|
|
e3 = mymax (factor 600851475143 2) 0
|