The babylonian method to get the sqare root of any number, yes, the one that takes an estimation, usually dividing the number by two, and then it takes the original number and add it to the estimation, then the result is divided by two, and there you got an iteration; the babylonian method is to do this iteration till get the sqare root

On code, that can be represented as a formula:

x = (x + number/x)/2.0

number is the number from we want to get the swareroot
x starts as the number divided by two
At the end, x will be the squareroot of the desired number

To make the computer repeat the mothod untill get the desired number, I used a while loop where te condition was:

x*x number> 0.00000000001

That means that the program will run the formule while the diference between the initial number and the current result is greater that that little number. NOTE, you have to take the difference as an absolute value

It was an easy code, because the babylonian did all the math, really, those people were smarta…

As always:

Github code

CC BY 4.0 WSQ13: Those Babylonians are crazy by charliegdrummer is licensed under a Creative Commons Attribution 4.0 International License.