A number is called an Automorphic number if its square ends in the same digits as the number itself.
For example, N=6 is an automorphic number because 6*6=36
N=25 is an automorphic number because 25*25=625
For other java programs click
https://wordpress-343193-1101484.cloudwaysapps.com/patterns-part-4strings
Write a program to accept a number and print whether it is an automorphic number or not.
import java.io.*;
class automorphic//one whose square ends in the same digits as the number itself e.g., 25
{
public static void main() throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
int num=Integer.parseInt(br.readLine());
int pro=(int)Math.pow(num,2);
if(pro%10==num||pro%100==num)
{
System.out.println("AN Automorphic Number");
}
else
{
System.out.println("Not An Automorphic Number");
}
}
}Output:
Enter a number
6
AN Automorphic Number
for more videos related to java click https://www.youtube.com/user/trushnatej