python代码
class Solution_2():
def sqrl(self, num):
num = float(num)
i = True
t = 1
while i:
if (t+1)**2 > num:
s = 0.1
n = num
x, y, x_b = t, t, t
while num - t ** 2 >= 1e-4 :
if t ** 2 - num != 0:
n = (n - x * y) * 100 # 是除号内部的东西
def get_next_M(x_b, n):
for j in range(1, 10):
if j * (20 * x_b + j) < n:
continue
else:return j-1,20 * x_b + j-1
x, y= get_next_M(x_b, n) # 这个是除号外边的,是分子,x=2,y=42
t = t + s * x
x_b= x_b*10 + x #x_b记录的是之前的x值,22
s = s/10
print(x, t, s, x_b)
i = False
else:
t += 1
print("个位是:%d"%t)
return t
b = Solution_2()
t = b.sqrl(40)