"python Exercise 003" an integer, which plus 100 is a complete square number, plus 168 is a complete square number, how much is this number?
-------------------------------------------------
The so-called "total square number", that is, open the root of the root is still an integer.
The math slag is thinking this way: suppose the number i is within 10000. First step: x = sqrt (i+100). if x = = Floor (x), It proves that X is an integer. The second step is the same, but remember to restore the square root x**2, plus 168, and then open the square root, get y, and then determine whether it is an integer. After these two judgments, all can be passed, then the whole number is Asked.
1 ImportMath2 3 forIinchRange (10000):4x = math.sqrt (i + 100))5 ifx = =Math.floor (x):6y = math.sqrt (x**2 + 168)7 ify = =Math.floor (y):8 Print(i)9 break
The answer is 21, good small integer ah ...
Python exercise 003: Total square number