Bigger numbers, try parallel computation
parent
42afd893c9
commit
47b3230d69
|
@ -3,11 +3,28 @@ The Simplest Math Problem No One Can Solve - Collatz Conjecture
|
||||||
https://youtu.be/094y1Z2wpJg
|
https://youtu.be/094y1Z2wpJg
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Control.Monad ()
|
import Control.Parallel.Strategies (parMap, rdeepseq, rpar)
|
||||||
import Debug.Trace (trace)
|
import Data.Set (fromList)
|
||||||
|
import Debug.Trace (trace)
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = print $ take 100 $ map f [2^1000..]
|
main = do
|
||||||
|
let results =
|
||||||
|
parMap rdeepseq f [10^100_000..10^100_000+100] :: [Integer]
|
||||||
|
print (fromList results)
|
||||||
|
-- main = print $ fromList $ dxs
|
||||||
|
-- main = print $ fromList $ take 300 $ map f [2^100_000..]
|
||||||
|
-- fromList [100001,717859]
|
||||||
|
|
||||||
|
-- main = print $ fromList $ take 3 $ map f [2^310997..]
|
||||||
|
-- main = print $ f $ 2^310997 + 2
|
||||||
|
|
||||||
|
lst :: [Integer]
|
||||||
|
lst = take 300 [2^100_000..]
|
||||||
|
|
||||||
|
dxs :: [Integer]
|
||||||
|
dxs = parMap rpar f lst
|
||||||
|
|
||||||
|
|
||||||
f :: Integer -> Integer
|
f :: Integer -> Integer
|
||||||
f n = s 1 n
|
f n = s 1 n
|
||||||
|
|
Loading…
Reference in New Issue