[ create a new paste ] login | about

Link: http://codepad.org/kc0C7DwP    [ raw code | output | fork ]

johannes - Haskell, pasted on Feb 27:
1
2
3
4
5
6
module Main where

newt x i n | i == 0    = n
           | otherwise = let f = newt x (pred i) n in (f + x/f) / 2

main = do print $ [newt 5 x 2 | x <- [0 .. 5]]


Output:
1
[2.0,2.25,2.23611111111111,2.2360679779158,2.23606797749979,2.23606797749979]


Create a new paste based on this one


Comments: