Last week the teacher gave us another problem to work on. As the title suggests, we had to create a function that would return the approximate square root of a number, using the Babylonian Method.
First I had to understand exactly how the method works, so I watched this video:
However, I still didn’t understand how I would know when it was accurate enough. My classmate Elu explained it to me, telling me that it should be when the difference between two successive answers gotten from the formula differed only by 0.0001 or less.
Having fully understood the mathematics, I proceeded to write my code: