Created
February 21, 2011 14:30
-
-
Save emonkak/837122 to your computer and use it in GitHub Desktop.
Looping.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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