Q-WAP TO CHECK IF A NUMBER IS AUTOMORPHIC OR NOT?

import java.io.; 
class auto
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n=0,num=0;
System.out.println("enter any number"); n=Integer.parseInt(br.readLine());
auto.automorphic(n);
}
public static void automorphic(int n)
{
int num=n,p=1;
while(n>0)
{
n=n/10;
p=p10;
}
if((num*num)%p==num)
{
System.out.println("automorphic");
}
else
{
System.out.println("not automorphic");
}
}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s