Anonymous user
Pascal's triangle: Difference between revisions
→{{header|Haskell}}
m (→{{header|F#}}: header cleanup) |
|||
Line 935:
f n = [1] ++ (map sum $ split y) ++ [1]
where y = f $ n - 1</lang>
With binomial coefficients:
<lang haskell>fac = product . enumFromTo 1
binCoef n k = (fac n) `div` ((fac k) * (fac $ n - k))
pascal n = map (binCoef $ n - 1) [0..n-1]</lang>
Example:
|