Question 3 :

Write a program to accept s number and check whether the number is an Automorphic Number or not

Explanation :

An automorphic number is an integer whose square ends with the given integer
Example : Square of 76 is 5776
Other examples are 25 and 6


import java.util.*;
public class automorphicNum
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter a number");
        int num=sc.nextInt();
        
        int sq=num*num;
        int temp=num;
        int count=0;
        while(temp>0)
        {
           count++;
            temp=temp/10;
        }
        int end=sq%(int)Math.pow(10,count);
        
        if(num ==end)
        System.out.println(num+" is  an automorphic number");

        else
        System.out.println(num+" is not an automorphic number");
    }
}

           
    
Codely Prompt ----->java automorphicNum.java
Enter a number
25
25 is a automorphic number
    
                
Codely Prompt ----->java perfectNum.java
Enter a number
21
21 is not a automorphic number 
                
            
                
Codely Prompt ----->java perfectNum.java
Enter a number
76
76 is a automorphic number 
                
            

Contribution by :-

Abhishek Image

Abhishek Raj