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

Calculate Compound Interest in JavaScript

How to make simple bill maker by using python tkinter

Admin Login Page Using HTML and CSS