fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. double mySqrt(int);
  4. int main(void){
  5. int n;
  6. for( n=0; n<=30; n++ ){
  7. printf( "√(%d) = %f\n", n, mySqrt(n) );
  8. }
  9. return 0;
  10. }
  11. double mySqrt(int n){
  12. return exp(0.5*log(n));
  13. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
√(0) = 0.000000
√(1) = 1.000000
√(2) = 1.414214
√(3) = 1.732051
√(4) = 2.000000
√(5) = 2.236068
√(6) = 2.449490
√(7) = 2.645751
√(8) = 2.828427
√(9) = 3.000000
√(10) = 3.162278
√(11) = 3.316625
√(12) = 3.464102
√(13) = 3.605551
√(14) = 3.741657
√(15) = 3.872983
√(16) = 4.000000
√(17) = 4.123106
√(18) = 4.242641
√(19) = 4.358899
√(20) = 4.472136
√(21) = 4.582576
√(22) = 4.690416
√(23) = 4.795832
√(24) = 4.898979
√(25) = 5.000000
√(26) = 5.099020
√(27) = 5.196152
√(28) = 5.291503
√(29) = 5.385165
√(30) = 5.477226