YouTip LogoYouTip

Python Exercise Example3

# Python2.x Python Exercise Example 3 [![Image 3: Python 100 Examples](#) Python 100 Examples](#) **Question:** An integer, when added to 100, is a perfect square, and when added to another 168, is also a perfect square. What is the number? **Program Analysis:** Assume the number is x. 1. Then: x + 100 = n 2, x + 100 + 168 = m 2 2. Calculate the equation: m 2 - n 2 = (m + n)(m - n) = 168 3. Set: m + n = i, m - n = j, i * j = 168, at least one of i and j is even 4. We can get: m = (i + j) / 2, n = (i - j) / 2, i and j are either both even or both odd. 5
← Python Exercise Example4Python Exercise Example2 β†’