module Exercise_3 where import Data.Ratio import Data.List choose :: Integer -> Integer -> Integer n `choose` k = product [n-k+1..n] `div` product [1..k] bernoulli :: Integer -> Rational bernoulli n | (n/=1) && (mod n 2 == 1) = 0 | otherwise = sum [sum [ ((-1)^v)*(choose k v)*(v^n)%(k+1) | v<-[0..k]] | k<-[0..n]]