-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew1.java
More file actions
56 lines (41 loc) · 1.09 KB
/
Copy pathNew1.java
File metadata and controls
56 lines (41 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Palindrom logic is to be build ..
// Factorial
// Fibonacci
// Prime No.
// Reverse a no.
// Reverse a String
// Array all types Questions.
// Automorphic Number
// PetersonNumber
// AnagramString
// Count the characters in a string
import java.util.Scanner;
public class New1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a no. to check Automorphic");
int num = sc.nextInt();
int square = num*num;
if(isAutomorphic( num , square))
{
System.out.println("The No. is AutoMorphic.");
}
else
{
System.out.println("The No. is not AutoMorphic.");
}
}
public static boolean isAutomorphic(int num, int square)
{
int cnt = 0;
int temp = num;
while(temp>0)
{
temp = temp/10;
cnt++;
}
int lastDigits = square % (int) Math.pow(10, cnt);
return lastDigits == num;
}
}
// if the class is not public we can make multiple classes in a class.