text: Automorphic Number | Java program to check if a number is Authomorphic ; Function to check Automorphic number ; Store the square ; Start Comparing digits ; Return false , if any digit of N doesn ' t ▁ ▁ match ▁ with ▁ its ▁ square ' s digits from last ; Reduce N and square ; Driver method
code: class Test { static boolean isAutomorphic ( int N ) { int sq = N * N ; while ( N > 0 ) { if ( N % 10 != sq % 10 ) return false ; N /= 10 ; sq /= 10 ; } return true ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( isAutomorphic ( N ) ? " Automorphic " : " Not ▁ Automorphic " ) ; } }