puts “Hello World”
def squareroot(a)
u=a
l=0
while (l<=u)
m = l + (u-1)/2
if (m2) < a
l = m + 1
elsif (m2) > a
u = m-1
elsif
m**2 == a
return m
else
return l-1
I guess it is never coming out of your while loop. Have a look at the
Rails Guide on debugging to find out how to break into code using
ruby_debug and see what is going on. Also you could try putting some
write statements in the function to see what is happening.
Hint: It may not help but what happens if you try squareroot(55.0)?
If that helps make sure you understand why (using debug or print
statements).