Automorphic Number
In mathematics, an automorphic number is a number whose square "ends" in the same digits as the number itself.
import java.util.*; class Automorphic { public static void main(String args[]) { int x,i,x1,nod; System.out.println("Enter a number"); Scanner in = new Scanner(System.in); x = in.nextInt(); x1=x; for(i=0;x1>0;i++) x1=x1/10; nod=(int)Math.pow(10,i); if((x*x)%nod==x) System.out.println(" AUTOMORPHIC"); else System.out.println("NOT AUTOMORPHIC"); } }
Comments
Post a Comment