Skip to content

Instantly share code, notes, and snippets.

@Adals20
Created April 6, 2017 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adals20/a2cd7ce93e9997a3d35cb8ff07e51443 to your computer and use it in GitHub Desktop.
Save Adals20/a2cd7ce93e9997a3d35cb8ff07e51443 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cmath>
using namespace std;
float Baby(double x){
double error = 0.0001, y;
y = x;
while((y-x/y)>error){
y = (y+x/y)/2;
}
return y;
}
int main(){
double x, y;
cout << "Ingrese un numero para calcular la raiz por el metodo Babylonian: ";
cin >> x;
y = Baby(x);
cout << "El resultado es: "<<y<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment