update 69
This commit is contained in:
parent
dfa7820a1c
commit
ef3b6b170b
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user