text: Automorphic Number | 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 code
code: < ? php function isAutomorphic ( $ N ) { $ sq = $ N * $ N ; while ( $ N > 0 ) { if ( $ N % 10 != $ sq % 10 ) return -1 ; $ N /= 10 ; $ sq /= 10 ; } return 1 ; } $ N = 5 ; $ geeks = isAutomorphic ( $ N ) ? " Automorphic " : " Not ▁ Automorphic " ; echo $ geeks ; ? >