fork download
  1. root :: Integer -> Integer -> Integer
  2. root a b = findAns sequence where
  3. sequence = iterate (\x -> (a1 * x + b `div` (x ^ a1)) `div` a) 1
  4. a1 = a - 1
  5. findAns (x:xs@(y:z:_)) | x == y || x == z = min y z
  6. | otherwise = findAns xs
  7.  
  8. main :: IO ()
  9. main = do
  10. print $ root 3 8
  11. print $ root 3 9
  12. print $ root 2 (2 * 100^2000) // first 2001 digits of the square root of 2
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:12:54: parse error on input `of'
stdout
Standard output is empty