GatoBooster

Metodo_de_Newton

Aug 9th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. //gcc 5.4.0
  2. #include  <stdio.h>
  3. #include  <math.h>
  4. #define error 0.000000001
  5.  
  6. int main(void)
  7. {
  8.     long long numero;
  9.     long double raiz;
  10.    
  11.     scanf("%lld",&numero);
  12.    
  13.     raiz = numero / 2.0;
  14.    
  15.     while(fabs(numero -(raiz * raiz)) > error)
  16.     {
  17.         raiz = ((raiz / 2.0)+(numero /(2*raiz)));
  18.     }
  19.    
  20.     printf("%Lf",raiz);
  21.    
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment