AB * AB = (10 * a + B) * (10 * a + B) = 100 * a + 10*2 * a * B + B * B = a * a + 2 * a * B + B * B = (a + B) * (a + B)
Abc * abc = (100 * a + 10 * B + c) * (100 * a + 10 * B + c)
= 10000 * a + 2000 * a * B + 100 * B + 200 * a * c + 20 * B * c + c * c
= A * a + 2 * a * B + B * B + 2 * a * c + 2 * B * c + c * c
= (A + B) ^ 2 + 2 * c * (a + B) + c * c
= (A + B + c) * (a + B + c)
Similarly, we can know that the four-digit and five-digit numbers are the same,
That is, n x n is equal to n x n.
In number theory, there is a conclusion: "The nine-remainder number of the product of a number is equal to the product of the Nine-remainder number." When the remainder is 0, this number is nine.
[Csharp]
# Include "stdio. h"
Int main ()
{
Int I, n, sum;
While (scanf ("% d", & n )! = EOF & n! = 0)
{
Sum = 1;
For (I = 0; I <n; I ++)
Sum = (sum * n) % 9;
If (sum = 0)
Printf ("9 \ n ");
Else
Printf ("% d \ n", sum );
}
Return 0;
}