--Originally published at May The Code be With You
Hello, Young Padawans!
Today, we are going to calculate a square root using an unconventional method, the Babylonian Method.
You may ask “What the heck is a Babylonian?!”. Well, Babylonials were an ancient culture who gave a lot to our math knowloge, by creating methods like this to calculate certain things.
This particuliar method consist in cutting a rectangle until it gives you the closest number to a square. Of course we are not cutting anything, we will just follow the formula.
So, the formula basically says “Take the number you want to know its square root, add the closest perfect square number to it. And divide all that by the square root of the perfect square number multiplied by two”
I know it may sound a little complicated, but here is a video to explain it in a simplier way: https://www.youtube.com/watch?v=sFMK3v879kg
As a human, you have a natural sense of comparission between number, so in that way you can know which perfect square number to use, but in your program you will have to make a for loop and increase the number and multiply it by itself in order to get the closest one, simple.
Hope It can help you.