import System.IO
-- A function to test if a number is prime, takes an integer and returns a
-- boolean.
isPrime :: Int -> Bool
isPrime n
| n < 2 = False
-- Try dividing by all numbers from 2 to sqrt(n).
| otherwise = all (\i -> n `mod` i /= 0) [2..(floor . sqrt . fromIntegral) n]
-- Main program starts here.
main :: IO ()
main = do
putStr "What is your name? "
hFlush stdout
name <- getLine
putStrLn ("Hello, " ++ name ++ "!")
putStr "What is your favorite number? "
hFlush stdout
number <- fmap (read :: String -> Int) getLine
putStr ("Your favorite number is " ++ show number)
if isPrime number
then putStrLn ", and that's a prime number!"
else putStrLn ". It's not a prime number, but that's okay!"