Title: An integer plus 100 after it is a perfect square, plus 168 is a perfect square, what is the number is how much?
Program analysis:
Assuming that the number x.
1, then: x + 100 = n2, x + 100 + 168 = m2
2, calculation equation: m2 - n2 = (m + n) (m - n) = 168
3, is provided: m + n = i, m - n = j, i * j = 168, i and j is an even number at least one
4, can be obtained: m = (i + j) / 2, n = (i - j) / 2, i and j are either both even or both odd.
5, 3, and 4 derived from know, I and j are both an even number greater than or equal to 2.
6, since i * j = 168, j> = 2, then 1 <i <168/2 + 1.
7, all numbers next cycle i can be calculated.
Specific achieve the following:
#include <stdio.h>
int main (void)
{
int i, j, m, n, x;
for (i = 2; i <= 168 / 2; i=i+2)
{
if (168 % i == 0)
{
j = 168 / i;
if ( i > j && (i + j) % 2 == 0)
{
m = (i + j) / 2;
n = (i - j) / 2;
x = n * n - 100;
printf ("%d + 100 = %d * %d\n", x, n, n);
printf ("%d + 268 = %d * %d\n", x, m, m);
}
}
}
return 0;
}