#include <stdio.h> #include <math.h> int main(){ float x,x1,x2; scanf("%f",&x); x1=x/2; x2=(x1+x/x1)/2; while(fabs(x1-x2)>1e-5){ x1=x2; x2=(x1+x/x1)/2; } printf("%.3f\n",x2); return 0; }
Double click to view unformatted code.