Skip to content

Commit 34b0b9a

Browse files
Palindrome number
Palindrome number Co-Authored-By: Manish Upadhyay <ermanishupadhyay@gmail.com>
1 parent 12c7a5c commit 34b0b9a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package JavaPrograms;
2+
3+
public class PalindromeNumber {
4+
5+
public static void main(String[] args) {
6+
// A Palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers.
7+
//It can also be a string like LOL, MADAM etc.
8+
9+
int num = 121;
10+
int rev = 0;
11+
12+
int actualNum = num;
13+
14+
while(num != 0) {
15+
int n = num % 10;
16+
rev = rev * 10 + n;
17+
num = num / 10;
18+
}
19+
System.out.println(rev);
20+
21+
if(actualNum == rev) {
22+
System.out.println(actualNum + " is a Palindrome");
23+
}
24+
else {
25+
System.out.println(actualNum + " is not a Palindrome");
26+
}
27+
}
28+
29+
}

0 commit comments

Comments
 (0)