Anonymous user
Stirling numbers of the first kind: Difference between revisions
m
→{{header|Haskell}}
Line 479:
import qualified Data.MemoCombinators as Memo
stirling1 :: Integral a => (a
stirling1 = Memo.
where
f (n, k)
| n == 0 && k == 0 = 1
| n > 0 && k == 0 = 0
| k > n = 0
| otherwise = stirling1 (pred n
main :: IO ()
Line 493:
mapM_ (printf "%10d") ([0..12] :: [Int]) >> printf "\n"
printf "%s\n" $ replicate (13 * 10 + 3) '-'
mapM_ (\row -> printf "%2d|" (fst $ head row) >>
mapM_ (printf "%10d" .
printf "\nThe maximum value of S1(100, k):\n%d\n" $
maximum ([stirling1 (100, n) | n <- [1..100]] :: [Integer])
where
table :: [[(Int, Int)]]
|