This wsq was easier than i thought, first I search hoe to use the babylonian method in youtube, so I found these two videos about it:

https://www.youtube.com/watch?v=jTWxFGmWoZg

https://www.youtube.com/watch?v=sZmz7znP6x0

After I analyze the video in detail I finally figure it out how to make a functional .cpp programm in any editor.

Babylonians were freaking smart! in school, teachers never taught me how to calculate the sqrt of a number without a machine, but now…I totally get it!

Here´s my code:

 <iostream>
using namespace std;

double babylonian(double number) {
 double failure= 0.00001;
 double x= number;
 while((x - number/x) > failure) {
 x = (x + number/x)/2;
 cout<<"The intermediate result is " << x <<endl;
 }
 return x;
}

void newline(){
  cout<<endl;
}

int main() {
 double num;
 cout<<"Hi, I´m a calculator of the square root of a number using the babylonian method"<<endl;
 newline();
 cout<<"Introduce the number "<<endl;
 newline();
 cin>>num;
 double result = babylonian(num);
 cout<<"The square root of "<<num<<" equals to "<<result<<endl;

 return 0;
}

Here´s my code on github:

https://github.com/everibarra/TC101-C-/blob/master/wsq13.cpp

CC BY 4.0 #WSQ13 by Ever Ibarra Almaral is licensed under a Creative Commons Attribution 4.0 International License.