• + 0 comments

    Haskel code

    calcex :: Int -> Double -> Double
    calcex 10 _ = 1.0
    calcex n x = 1.0 + x / fromIntegral n * calcex (n + 1) x
    
    evaluateSeries :: Double -> Double
    evaluateSeries x = calcex 1 x
    
    main :: IO ()
    main = do
        n <- readLn :: IO Int
        inputs <- mapM (\_ -> readLn :: IO Double) [1..n]
        let outputs = map evaluateSeries inputs
        mapM_ print outputs