Skip to content

Instantly share code, notes, and snippets.

@ar1a
Created January 25, 2019 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ar1a/aa0d1df891a717d72d05f0566579d050 to your computer and use it in GitHub Desktop.
Save ar1a/aa0d1df891a717d72d05f0566579d050 to your computer and use it in GitHub Desktop.
fac :: Int -> Int
fac = product . flip take [1..]
pascals :: Int -> [Int]
pascals n =
map (\r -> fac n `div` (fac r * fac (n - r))) [0..n]
main :: IO ()
main = do
input <- getLine
putStrLn $ unlines . map ((unwords . map show) . pascals) . flip take [0..] . read $ input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment