Created
September 1, 2017 18:18
-
-
Save mvallebr/b1c3a2da8280963e05108c1c9964ac2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Control.Applicative | |
| import Control.Monad | |
| import System.IO | |
| import Text.Printf | |
| eterm 0 n cf f cx x = 1 + (eterm 1 n 1 1 x x) | |
| eterm cn n cf f cx x | |
| | cn >= n = 0 | |
| | otherwise = (cx/cf) + (eterm (cn+1) n (cf * (f+1)) (f+1) (cx*x) x) | |
| fe :: Double -> Double | |
| fe x = eterm 0 10 0 0 0 x | |
| main :: IO () | |
| main = do | |
| n_temp <- getLine | |
| let n = read n_temp :: Int | |
| forM_ [1..n] $ \a0 -> do | |
| x_temp <- getLine | |
| let x = read x_temp :: Double | |
| printf "%.4f\n" (fe x) | |
| getMultipleLines :: Int -> IO [String] | |
| getMultipleLines n | |
| | n <= 0 = return [] | |
| | otherwise = do | |
| x <- getLine | |
| xs <- getMultipleLines (n-1) | |
| let ret = (x:xs) | |
| return ret | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment