import java.io.*;
class Automorphic_num
{
public static void main(String args[])throws IOException
{
InputStreamReader reader = new InputStreamReader(System.in);
BufferedReader input = new BufferedReader(reader);
int n,sq,d,count=0,tsq;
System.out.print("Enter a number : ");
n = Integer.parseInt(input.readLine());
sq = n * n;
tsq=sq;
do
{
d = tsq%10;
count++;
tsq = tsq/10;
}while(tsq!=0);
for(int i=2 ; i<=count ; i++)
{
if(i==count)
{
i--;
i = (int)Math.pow(10,i);
int ers = sq % i;
if(ers == n)
{
System.out.println("It is a automorphic number");
break;
}
else
{
System.out.println("It is not a automorphic number");
break;
}
}
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment