1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import Control.Parallel parfindDivisors n = force f1 `par` (force f2 `pseq` (f1 ++ f2)) where f1=filter g [1..(quot n 4)] f2=filter g [(quot n 4)+1..(quot n 2)] g z = n `rem` z == 0 force xs = go xs `pseq` () where go (_:xs) = go xs go [] = 1 findDivisors n = filter g [1..(quot n 2)] where g z = n `rem` z == 0 main = print (parfindDivisors 1000000000) |