The teacher assigned homework to Insus.net to do, topics such as title.
Interested users can also practice. Now Insus.net's answer is as follows, but the teacher has not looked, so the answer is correct or the best, is not sure, but for reference.
The first time the fastest way to achieve:
Copy Code code as follows:
for (int i = 1; I <= i++)
{
Int J = i * I;
if (J >= 50)
Response.Write (i + "x" + i + "=" + j + "<br/>");
}
The results were as follows:
Upon completion of the above, Insus.net immediately remembered that the teacher must not have such a simple question. Will the teacher to insus.net implementation, the product is less than 50 of the two numbers multiplied by the need to cycle, to reduce performance, so immediately modify the program just completed:
First we find out the number of square roots of 50, and the data type of double, which means that there can be decimal, and convert it to integer:
Copy Code code as follows:
int min = (int) math.sqrt (50);
In this way, we can see which integer started the loop. But one day, it is no longer the calculated product is 50, but instead of the product 64, its square root is 8. If the square of 8 is just 64, and the title is greater than 64, the correct start is 9. So it's still the following judgment:
Copy Code code as follows:
if (Math.pow (min, 2) < 50)
min = 1;
The final insus.net answer is as follows:
Copy Code code as follows:
for (int i = min; I <= i++)
{
Int J = i * I;
Response.Write (i + "x" + i + "=" + j + "<br/>");
}
The result is the same as for the first time.