### What is Automorphic number in Java

A number is said to be a automorphic number if and only if the square of the given number ends with the original number itself.

- An “Automorphic” number is the number which is contained in the last digit of its square.
- For example: 5, 6, 25, etc.
- Sample Input: 25
- Solution: The square of
**25**= 25 x 25 = 6**25**and**25**is present as the last two digit and ends with the original number itself. - Sample Output: 25 is an automorphic number

Let’s see another example:

- Sample Input: 5
- Solution: The square of
**5**= 5 X 5 = 2**5**and**5**is present as the last digit and ends with the original number itself. - Sample Output: 5 is an automorphic number

**// program to check Automorphic number
import java.util.Scanner;
class Automorphic
{
public static void main(String args[])
{
int num,sqr,flag=0,org_num;
Scanner sc=new Scanner(System.in);
System.out.println("Enter any number");
num=sc.nextInt();
org_num=num;
sqr=num*num;
do
{
if(num%10 != sqr%10)
{
flag=1;
break;
}
else
{
num=num/10;
sqr=sqr/10;
}
}while(num>0);
if(flag==0)
System.out.println(org_num+" is Automorphic number");
else
System.out.println(org_num+" is not Automorphic number");
}
}**

**Output:**