Automorphic Number Program in Java

An Automorphic number is a number whose square “ends” in the same digits as the number itself.

Examples: 5*5 = 25, 6*6 = 36, 25*25 = 625


import java.util.Scanner;

public class AutomorphicNumber
{
    public static void main(String[] args)
    {
        int n, sqrNum, temp,sqrNumRemainder,c = 0;
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter number=");
        n = sc.nextInt();
        temp=n;        
        while (temp > 0)
        {
            temp=temp/10;
            c++;
        }
        sqrNum = n * n;
        sqrNumRemainder= sqrNum%(int)Math.pow(10, c);
        if(sqrNumRemainder==n)
        {
            System.out.println("Automorphic Number");
        }
        else
        {
            System.out.println("Not Automorphic Number");
        }
        
        
    }
}


Output:

Enter number=25
Automorphic Number
What is Automorphic Number?
An Automorphic number is a number whose square “ends” in the same digits as the number itself. Examples: 5*5 = 25, 6*6 = 36, 25*25 = 625

What is Automorphic Number in Java?
An Automorphic number is a number whose square “ends” in the same digits as the number itself.
Examples: 5*5 = 25, 6*6 = 36, 25*25 = 625

What is Automorphic Number in C Language?
An Automorphic number is a number whose square “ends” in the same digits as the number itself.
Examples: 5*5 = 25, 6*6 = 36, 25*25 = 625

b. tech. bca icse java java tutorials learn java mca programs