import Data.List import Data.Ratio choose :: Integer -> Integer -> Integer n `choose` k = product [n-k+1..n] `div` product [1..k] bernoulli :: Integer -> Rational bernoulli n | n == 0 = 1 | otherwise = sum [((choose n k) % (k - n - 1)) * (bernoulli k) | k<-[0..(n-1)]]