Project Euler 14: performance compared to C and memoization
I'm currently working on project euler problem 14 . I solved it using a poorly coded program, without memoization, that took 386 5 seconds to run (see edit). Here it is: step :: (Integer, Int) -> Integer -> (Integer, Int) step (i, m) n | nextValue > m = (n, nextValue) | otherwise = (i, m) where nextValue = syr n 1 syr :: Integer -> Int -> Int syr 1 acc = acc syr x acc | even x = syr (x `div` 2) (acc + 1) | otherwise = syr (3 * x + 1) (acc + 1) p14 = foldl step (0, 0) [500000..999999] My question is about several comments in the thread related to this problem, where were mentionned execution