import Data.List import Data.Function import Data.Ratio bernoulli :: Integer -> Rational bernoulli n = if n `mod` 2 == 0 then sum[(-1)^v *(product [k-v+1..k] `div` product (enumFromTo 1 v)) * v^n%(k+1)|k<-enumFromTo 0 n,v<-enumFromTo 0 k] else 0