public class automorphic_number
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number to be checked ");
int n = sc.nextInt();
int square = n*n;
System.out.println(square);
String s = Integer.toString(n);
int l = s.length();
double power = Math.pow(10, l);
double rem = square%power;
if(rem==n)
System.out.println(n+" is an automorphic number");
else
System.out.println(n+" is not an automorphic number");
sc.close();
}
}
/*
Input : N = 76
Output : Automorphic
Explanation: As 76*76 = 5776
Input : N = 25
Output : Automorphic
As 25*25 = 625
Input : N = 7
Output : Not Automorphic
As 7*7 = 49
5
25
*/
No comments:
Post a Comment