0hc.net Menu
Home Overview
About Menu
Impressum

Probability

main = do putStrLn "Probability:" putStrLn "1. in sequence and recline" putStrLn "2. in sequence and no recline" putStrLn "3. no sequence and recline" putStrLn "4. no sequence and no recline" i <- scan "mode" a <- scan "amount" p <- scan "passes" putStrLn $ "Result: " ++ (show $ round $ prop i a p) fac = product . enumFromTo 1 prop :: (Num a, Floating b, Enum b) => a -> b -> b -> b prop i a p | i==1 = a**p | i==2 = fac a / fac (a-p) | i==3 = fac (a+p-1) / (fac p * fac (a-1)) | otherwise = fac a / (fac p * fac (a-p)) scan y = do putStrLn $ "Input " ++ y ++ ":" x <- getLine return (read x :: Double)
0hc.net    © 2001-2014 Harald Wolfsgruber