-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollatzMain.hs
More file actions
23 lines (19 loc) · 791 Bytes
/
Copy pathcollatzMain.hs
File metadata and controls
23 lines (19 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Main where
import Data.Time.Clock (diffUTCTime, getCurrentTime)
import System.Environment (getArgs)
import Collatz
main = do
args <- getArgs
let count | null args = 100000
| otherwise = read (head args)
start1 <- getCurrentTime
let range = [1..count]
let s = exhaustCollatz range
putStrLn $ "Sequentially proven, the Collatz conjecture up to " ++ show count ++ " is " ++ show s ++ "."
end1 <- getCurrentTime
putStrLn $ show (end1 `diffUTCTime` start1) ++ " elapsed.\n"
start2 <- getCurrentTime
let p = parExhaustCollatz range
putStrLn $ "Proven in parallel, the Collatz conjecture up to " ++ show count ++ " is " ++ show p ++ "."
end2 <- getCurrentTime
putStrLn $ show (end2 `diffUTCTime` start2) ++ " elapsed.\n"