Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 15 Online
OpenStudy (anonymous):

in lecture 3 find square root of a number. there is code while abs(ans**2 - x) >= epsilon and ans <= x: I can understand the first equation, but why do we need ans <= x? I tried remove this ans<=x , looks still can get correct answer. Can you help me?

OpenStudy (anonymous):

I believe you will find it stops the program going into an infinite loop if the initial value of x is negative.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!