challenges/e2/e2.ghc.hs

6 lines
200 B
Haskell

fibsum prev curr acc max | curr > max = acc
| rem curr 2 == 0 = fibsum curr (prev + curr) (acc + curr) max
| otherwise = fibsum curr (prev + curr) acc max
main = print (fibsum 1 1 0 4000000)