Automorphic Number

Automorphic Number is a number whose last digits of square of the number is equal to the original number.

Example 1: 25. 252 = 625. We observe that the last two digits of 625 is 25 which is equal to the original number. Hence it is an Automorphic Number.

Example 2: 6. 62 = 36. We observe that the last digit of 36 is 6 which is equal to the original number. Hence it is an Automorphic Number.

Example 3: 12. 122 = 144. Here the last two digits of 144 is not equal to the original number. Hence it is not an Automorphic Number.

Java
import java.util.*;
public class AutomorphicNumber
{
    public static void main(String args[])
    {
        int n=0,r=0,nCopy=0,count=0;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter a number: ");
        n=sc.nextInt();
        nCopy=n;
        while(n>0)
        {
            count++;
            n=n/10;
        }
        n=nCopy;
        r=(n*n)%(int)Math.pow(10,count);
        if(n==r)
        {
            System.out.println(n+" is an Automorphic Number");
        }
        else
        {
            System.out.println(n+" is not an Automorphic Number");
        }
    }
}
Java