finished haskell
This commit is contained in:
parent
eb0954b57a
commit
bf1adf6b06
11
e3/e3.hs
11
e3/e3.hs
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue