real 0m1.409s
user 0m1.406s
sys 0m0.002s
$ time ./smp3 +RTS -N2
[90,7,7,0,5,63,7,11,31,3]
real 0m0.834s
user 0m1.564s
sys 0m0.046s
$ time ./smp3 +RTS -N4
[90,7,7,0,5,63,7,11,31,3]
real 0m0.545s
user 0m1.576s
sys 0m0.036s
module Main where
import Data.Maybe
import Control.Parallel.Strategies
import Control.Parallel
factors n = let candidates = [2..floor (sqrt (fromInteger n))]
in catMaybes $ map (\x ->
if n `mod` x == 0
then Just (x, n `div` x)
else Nothing) candidates
bigNums = [2000000000000..]
answer = (parMap rwhnf) (length . factors) (take 10 bigNums)
main = print answer
Name:
Anonymous2008-05-16 14:09
>>20
I have proven them all wrong. Was that a bad thing to do?