Hi! This WSQ consisted on applying the babylonian method to obtain the square root of a given number. This seemed easy but I had to make some research to understand the concept and to apply it. First I watched this video to familiarize with the method: https://www.youtube.com/watch?v=jTWxFGmWoZg. So the first issue I had was to “guess” the number which square would get closer to the given number. After several attepts, I found a way to solve it by using a loop which increased a number until its square became bigger that the number, and then I substracted 1. Finally, I had to search for a way to make two floats have similar values. I found page that talked about precision by using the absolute value of the substraction, I tested it and it worked. Page: http://codereview.stackexchange.com/questions/17923/checking-if-two-floating-point-numbers-are-equal

Here’s the code on GitHub: https://github.com/CarlosGallegosT/Codes007/blob/master/Babylonian_Method.cpp

               

CC BY 4.0 Babylonian Method #WSQ13 by Carlos Gallegos is licensed under a Creative Commons Attribution 4.0 International License.