import java.io.*;
class Test {
// Function to check Automorphic number
static boolean isAutomorphic(int N)
{
// Store the square
if(N < 0) N = -N;
int sq = N * N;
// Start Comparing digits
while (N > 0) {
// Return false, if any digit of N doesn't
// match with its square's digits from last
if (N % 10 != sq % 10)
return false;
// Reduce N and square
N /= 10;
sq /= 10;
}
return true;
}
// Driver method
public static void main
(String[] args
) {
int N = 5;
System.
out.
println(isAutomorphic
(N
) ? "Automorphic" : "Not Automorphic"); }
}
aW1wb3J0IGphdmEuaW8uKjsKY2xhc3MgVGVzdCB7CgkvLyBGdW5jdGlvbiB0byBjaGVjayBBdXRvbW9ycGhpYyBudW1iZXIKCXN0YXRpYyBib29sZWFuIGlzQXV0b21vcnBoaWMoaW50IE4pCgl7CgkJLy8gU3RvcmUgdGhlIHNxdWFyZQoJCWlmKE4gPCAwKSBOID0gLU47CgkJaW50IHNxID0gTiAqIE47CgoJCS8vIFN0YXJ0IENvbXBhcmluZyBkaWdpdHMKCQl3aGlsZSAoTiA+IDApIHsKCQkJLy8gUmV0dXJuIGZhbHNlLCBpZiBhbnkgZGlnaXQgb2YgTiBkb2Vzbid0CgkJCS8vIG1hdGNoIHdpdGggaXRzIHNxdWFyZSdzIGRpZ2l0cyBmcm9tIGxhc3QKCQkJaWYgKE4gJSAxMCAhPSBzcSAlIDEwKQoJCQkJcmV0dXJuIGZhbHNlOwoKCQkJLy8gUmVkdWNlIE4gYW5kIHNxdWFyZQoJCQlOIC89IDEwOwoJCQlzcSAvPSAxMDsKCQl9CgoJCXJldHVybiB0cnVlOwoJfQoKCS8vIERyaXZlciBtZXRob2QKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpCgl7CgkJaW50IE4gPSA1OwoKCQlTeXN0ZW0ub3V0LnByaW50bG4oaXNBdXRvbW9ycGhpYyhOKSA/ICJBdXRvbW9ycGhpYyIgOiAiTm90IEF1dG9tb3JwaGljIik7Cgl9Cn0K