Latest web development tutorials

Python Exercise Example 3

Python Exercise Example 3

Python 100 Li Python 100 Li

Title: An integer plus 100 and plus it is a perfect square after 268, what is the number is how much?

Program analysis: less than 10 000 judgments, then the number of prescribing plus 100 plus 268 before prescribing, if the result of evolution after the following conditions are met, that is the result. See detailed analysis:

Source Code:

Examples (Python 2.0+)

#! / usr / bin / python # - * - Coding: UTF- 8 - * - import math for i in range (10000): # is converted to an integer value x = int (math. sqrt ( i + 100)) y = int (math. sqrt ( i + 268)) if (x * x == i + 100) and (Y * y == i + 268 ): print i

The above example output is:

21
261
1581

Python 100 Li Python 100 Li