Python code with Newton method


  • 0
    T
    class Solution(object):
        def isPerfectSquare(self, num):
            x = num 
            while x*x > num:
                x = (x + num/x) / 2
                print(x)
            return x * x == num
    
    

Log in to reply
 

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