Modify the program below to output square root of 207936 with help of the Babylonian method.
Branching
Babylonian square root
Report a typo
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))
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.