fork download
  1. import Data.Complex
  2. import Data.List
  3. main :: IO ()
  4. main = mapM_ (print . f) $ [1 .. 6] ++ [10, 20, 999, 1000]
  5. f :: Int -> Double
  6. f n = (!! n) $ nub $ sort [magnitude $ x :+ y | x <- a, y <- a]
  7. where a = [0 .. fromIntegral $ ceiling $ sqrt $ fromIntegral $ 4 * n]
  8.  
Success #stdin #stdout 0.04s 6324KB
stdin
Standard input is empty
stdout
1.0
1.4142135623730951
2.0
2.23606797749979
2.8284271247461903
3.0
4.123105625617661
6.324555320336759
58.0
58.008620049092706