Write a java program to input a number and check whether it is an automorphic or not. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Write a java program to input a number and check whether it is an automorphic or not.

An automorphic number is a number which is contained in the last digit(s) of its square. For example : 25 The square of 25 is 625 and 25 is present as the last two digits. Therefore, 25 is an automorphic number.

4th Feb 2018, 6:53 PM
Vansh Chopra
Vansh Chopra - avatar
5 Answers
+ 17
@Vansh U just need to see length of number entered and divide n^2 by 100... having zeroes equal to length of number
4th Feb 2018, 7:25 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 14
System.out.print(Math.pow(n,2)%100.0==n); //i think u should start thinking by yourself now
4th Feb 2018, 7:09 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 6
You can't divide every number by 100. The number can be 5. It is also an automorphic number.
4th Feb 2018, 7:15 PM
Vansh Chopra
Vansh Chopra - avatar
+ 6
That's why, I am facing problem. I tried it.
4th Feb 2018, 7:16 PM
Vansh Chopra
Vansh Chopra - avatar