• + 0 comments

    Haskell

    pascal n = take n $ iterate nextPascal [1] where 
        nextPascal l = [head l] ++ [a + b | (a, b) <- zip l (tail l)] ++ [last l]
        
    pascalStr n = map (unwords . map show) $ pascal n
    
    main = do
        n <- read <$> getLine
        putStrLn . unlines $ pascalStr n