所以我创建了这个小python程序,找到了数字的根:
def findRoot(number):
a = 0
aa = 0.00
aaa = 0.0000
aaaa = 0.000000
aaaaa = 0.00000000
x = 1
while x == 1:
if a * a > number:
break
else:
a = a + 1
a = a - 1
aa = aa + a
while x == 1:
if aa * aa > number:
break
else:
aa = aa + 0.01
aa = aa - 0.01
aaa = aaa + aa
while x == 1:
if aaa * aaa > number:
break
else:
aaa = aaa + 0.0001
aaa = aaa - 0.0001
aaaa = aaaa + aaa
while x == 1:
if aaaa * aaaa > number:
break
else:
aaaa = aaaa + 0.000001
aaaa = aaaa - 0.000001
aaaaa = aaaaa + aaaa
while x == 1:
if aaaaa * aaaaa > number:
break
else:
aaaaa = aaaaa + 0.00000001
aaaaa = aaaaa - 0.00000001
aaaaa = aaaaa + 0.000000009375465
print(aaaaa)
findRoot(64)
findRoot(81)
findRoot(36)
findRoot(784)
它没有小数点后面的数字,只有前几行(它只输出8作为根64),但现在输出是: 7.999999999999999。 0.000000000000001去哪儿了?为什么它适用于81,36和784?为什么这些数字不像DN那样宽松0.000000000000001呢?