fact :: Integral a => a -> a fact 0 = 1 fact x = x * fact (x - 1) solve :: (Show a, Integral a) => a -> String solve n | n < 50 = reverse . take 12 . reverse . show . fact $ n | otherwise = replicate 12 '0' main = putStrLn . solve =<< readLn