finished haskell

This commit is contained in:
Dan Ballard 2011-10-22 09:44:33 -07:00
parent eb0954b57a
commit bf1adf6b06
1 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,11 @@
factor n divisor factor n divisor
| (divisor == n-1 || n == 1) = [n] | (divisor >= n-1 || n == 1) = [n]
| rem n divisor == 0 = (factor (fromIntegral n/divisor) 2) ++ (factor divisor 2) | rem n divisor == 0 = (factor (n `div` divisor) 2) ++ (factor divisor 2)
| otherwise = factor n (divisor+1) | otherwise = factor n (divisor+1)
mymax [] acc = acc
mymax (x:xs) acc
| x > acc = mymax xs x
| otherwise = mymax xs acc
e3 = mymax (factor 600851475143 2) 0