☞☞☞ Click to see more outstanding Python blog ☜☜☜
Python includes exercises 3
Title: An integer that after 268 plus 100 plus and is a perfect square, what is the number is how much?
Program Analysis : Analyzing less than 10,000, then 100 plus the number of prescription, and then prescribing plus 268, if the result of the square root satisfies the following condition, i.e., is the result. See detailed analysis:
Source Code :
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import math
for i in range(10000):
#转化为整型值
x = int(math.sqrt(i + 100))
y = int(math.sqrt(i + 268))
if(x * x == i + 100) and (y * y == i + 268):
print i
Examples of the above output is:
21 261 1581