python求一个整数加上100和268后都是一个完全平方数,请问该数是多少
方法1:
import math
for i in range(-100, 10000):
m = math.sqrt(i + 100)
n = math.sqrt(i + 268)
if m % 1 == 0.0 and n % 1 == 0.0:
print(i)
方法2:
import math
for i in range(-100, 10000):
m = int(math.sqrt(i + 100))
n = int(math.sqrt(i + 268))
if m * m == i + 100 and n * n == i + 268:
print(i)