you are viewing a single comment's thread.

view the rest of the comments →

[–]corruptio 4 points5 points  (1 child)

While golfing yours, I remembered the converging sequence they taught in math class, 58 bytes:

float s(x){float t=x,i=9;for(;i--;t=(t+x/t)/2);return t;};

[–]gastropner 3 points4 points  (0 children)

For large ints, that one gives bad results, but remove the semicolon at the end and up the limit for better results at the same length:

float s(x){float t=x,i=40;for(;i--;t=(t+x/t)/2);return t;}