Skip to content

Commit 024f57c

Browse files
authored
check automorphicity of java
1 parent 9fd3485 commit 024f57c

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

checkautomorphic.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# https://www.facebook.com/permalink.php?story_fbid=1289077461428963&id=100009801635737
2+
# subscribed by jay patel
3+
# java program to find automorphic
4+
import java.util.*;
5+
class Automorphic
6+
{
7+
public static void main(String args[]) throws Exception
8+
{
9+
Scanner sc = new Scanner(System.in);
10+
System.out.print("Enter a Number : "); // Inputting the number
11+
int n = sc.nextInt();
12+
int sq = n*n; // Finding the square
13+
14+
String num = Integer.toString(n); // Converting the number to String
15+
String square = Integer.toString(sq); // Converting the square to String
16+
17+
if(square.endsWith(num)) // If the square ends with the number then it is Automorphic
18+
System.out.print(n+" is an Automorphic Number.");
19+
else
20+
System.out.print(n+" is not an Automorphic Number.");
21+
}
22+
}
23+

0 commit comments

Comments
 (0)