import Data.List import Data.Function (on) import Data.Char (ord) choose :: Integer -> Integer -> Integer n `choose` k = product [n-k+1..n] `div` product [1..k] bernoulli :: Integer -> Rational bernoulli 0 = 1 bernoulli n = sum [fromIntegral (choose n k) * ((bernoulli k) / (fromIntegral (k - n - 1))) | k <- [0..n-1]]