Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

public class Solution { public int mySqrt(int x) { double x0 = 1; do{ x0 = (x0+ x/x0)/2; }while(Math.abs(Math.pow(x0, 2) - x) >= 1); return (int)x0; } }

if x= 7,x0=2,then it goes to a dead loop,how to solve it ?

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.