Write a program to check a number is Automorphic or not in java



 Write a program to check a number is Automorphic or not in java

public class Automorphic
{
    public static void main(String args[]){
        int number376,digit=0,temp,square,last;
        temp=number;
        square=number*number;
        while(temp!=0){
            digit++;
            temp=temp/10;
        }
        
        last=square % (int)Math.pow(10,digit);
        if(number==last){
        System.out.println(number +" is Automorphic Number");
        }else{
        System.out.println(number +" is Not Automorphic Number");
        }
        
    }
}
Output
376 is Automorphic Number

Comments

Popular posts from this blog

Write a program to find sum of first 10 natural number in java

Write a program to find the sum of 1/2+4/3+5/6+8/7+9/10 using loop in java

Write a program to check a year is leap year or not in java