-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNC56.java
More file actions
30 lines (25 loc) · 705 Bytes
/
NC56.java
File metadata and controls
30 lines (25 loc) · 705 Bytes
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
public class NC56 {
public static boolean isPalindrome (int x) {
// write code here
if (x < 0) return false;
if (x / 10 == 0) return true;
while(x >= 0){
int div = 1;
while (x / div >= 1){
div *= 10;
}
int hi = x / div;
int low = x % 10;
if (hi != low) return false;
x = (x % div) / 10;
System.out.println(div);
System.out.println(x);
System.out.println();
}
return true;
}
public static void main(String[] args){
int i = 121;
System.out.println(isPalindrome(i));
}
}