not' :: Bool -> Bool
not' True = False
not' False = True

and' :: Bool -> Bool -> Bool
and' False y = False
and' True y = y

max' :: Integer ->Integer ->Integer
max' a b 
    | a>=b = a
    | otherwise = b

factorial :: Integer ->Integer
factorial 0 = 1
factorial x = x * factorial(x-1)

factorial' :: (Integral a) => a -> a
factorial' n = product [1..n]

isCloseEnough :: Double -> Double -> Bool
isCloseEnough a b
    | diff<=0.0001 = True
    | otherwise = False
    where 
      diff = abs (a-b)

sqrt_guess :: Double ->Double ->Double
sqrt_guess x g
    | isCloseEnough x (g*g) = g
    | otherwise             = sqrt_guess x g'
    where
      g' = (g+x/g)/2

sqrt' :: Double ->Double
sqrt' x = sqrt_guess x 1
