Square Root (Babylonian Method)

In this case we can see an example of recursiveness in a program. As always the source code is in GitHub.

The square root Babylonian method consists in doing a series of sums and divisions in order to calculate the value of the square root of a number. It is approximated by solving an equation that you can check in the page link pasted before.

This program is written so that it asks the user for the number, the number that he wants to use as a first guess and the number of runs or iterations it want to use to calculate the value. Any way the program should stop if the value of the next iteration is the same as the one before. 

After each iteration the number of the run and the estimated value ar displayed to show the user the different values calculated. 

This is my of my

CC BY 4.0 Square Root (Babylonian Method) by Manuel Lepe is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.