# Square root of a number # Use newton rhapson's method def sqrt(x) r = x r = (r + x/r) / 2 while r*r > x r end