Skip to content

Instantly share code, notes, and snippets.

@emonkak
Created February 21, 2011 14:30
Show Gist options
  • Save emonkak/837122 to your computer and use it in GitHub Desktop.
Save emonkak/837122 to your computer and use it in GitHub Desktop.
Looping.hs
import System.CPUTime
calc n n0 = n0 + (1 - 2 * (n `rem` 2))
looping 0 n _ = n
looping c n n0 = let n1 = calc n n0
in n1 `seq` looping (c - 1) n1 n
main = do
start <- getCPUTime
print $ looping 2147483647 1 0
end <- getCPUTime
print $ (fromInteger $ end - start) / (10 ^ 12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment