Babylonian square root

Report a typo

Modify the program below to output square root of 207936 with help of the Babylonian method.

Write a program in Scala 3
def sqrt(r: Int, x: Int = ???): Int =
if x * x != r then sqrt(r, ???)
else x

@main def babylonianSquareRoot =
println(sqrt(207936))
___

Create a free account to access the full topic