fork download
  1. #include<stdio.h>
  2.  
  3. double r(float x, int n){
  4. return n==0?x: (r(x,n-1)+x/r(x,n-1))/2;
  5. }
  6. int main(int argc, char const *argv[])
  7. {
  8. float x;
  9. scanf("%f",&x);
  10. printf("the square root of %f is: %lf\n",x,r(x,30.0));
  11. return 0;
  12. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
the square root of 0.000000 is: -nan