update 69

This commit is contained in:
sangge-rockpi 2024-01-24 18:25:02 +08:00
parent dfa7820a1c
commit ef3b6b170b

View File

@ -7,6 +7,12 @@ class Solution:
# Use Newton's method, return the smaller root
# fx = x ** 2 - c
# Xn-1 = 0.5 * (Xn + c / Xn)
if c == 0:
return 0
if c == 1:
return 1
x = c / 2
while True:
next_x = (x + c / x) / 2