why Newton method is wrong?


  • 0
    T

    For n = (x^2+x)/2, f(n) = x^2+x-2n.Then with Newton Method , x(n+1) = x(n) - f(n)/f'(n), It's x(n+1) = x(n) - (x^2+x+2n)/2x+1 = (x^2 + 2n) / 2x. Help me , thx.

    public:
        int arrangeCoins(int n) {
            int x = 1;
            unsigned long long tn = n<<1;
            while(x*(x+1) < tn){
                x = (x*x+tn)/(2*x+1);
            }
            return (int)x-1;
        }
    };  ```

Log in to reply
 

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