牛顿法

class Solution:
    def mySqrt(self, x: int) -> int:
        if x == any([0, 1]):
            return x
        now = x / 2
        while 1:
            if now * now - float(x) < 1:
                 return int(now)
            now = (x + now * now) / (2 * now)

 

相关文章:

  • 2021-11-09
  • 2022-01-22
  • 2021-07-07
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2021-11-23
  • 2021-10-07
  • 2021-07-31
  • 2021-12-08
  • 2021-08-08
相关资源
相似解决方案