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 number= 376,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");
}
}
}
Output376 is Automorphic Number
Comments
Post a Comment