What is Automorphic number in Java ?
Join the DZone community and get the full member experience.
Join For FreeIn mathematics an automorphic number (sometimes referred to as a circular number) is a number whose square "ends" in the same digits as the number itself.
For example,
52 = 25,
62 = 36,
762 = 5776,
and 8906252 = 793212890625,
so 5, 6, 76 and 890625 are all automorphic numbers.
And the logic behind :
int n=56; int d=1; int i; for(i=n;i>0;i=i/10) { d=d*10; } if((n*n)%d==n) { System.out.println(n+"\t"+"is Automorphic Number"); } else { System.out.println(n+"\t"+"is not Automorphic Number"); } }You can check full article from Geek On Java - Hub for Java and Android
Java (programming language)
Opinions expressed by DZone contributors are their own.
Comments