1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 module Main where 47 import IntLib 48 import MyRandom 49 import Prime 50 51 52 53 54 main :: IO () 55 main = getContents >>= \ cts -> mapM_ putStr (process (lines cts)) 56 57 58 59 60 process :: [String] -> [String] 61 process = doInput initState 62 63 64 65 66 doInput :: State -> [String] -> [String] 67 doInput state [] = [] 68 doInput state (l:ls) = doLine l (\state -> doInput state ls) state 69 70 71 72 doLine :: String -> (State -> [String]) -> State -> [String] 73 doLine cs cont rs 74 = if t then "Probably prime": rest else "Composite": rest 75 where n = readInteger cs 76 (t, rs') = multiTest 100 rs n 77 rest = cont rs' 78 79 80 81 82 type State = [Int] 83 initState = randomInts 111 47 84 85 86 87 88