class Palindrome {
public static void main(String args[]) {
int i;
Palindrome x = new Palindrome();
for (i = 1; i <= 100; i++) {
x.pali(i);
}
}
void pali(int number) {
int i;
int copy = number;
int rem, rev = 0;
for (i = 0; number != 0; i++) {
rem = number % 10;
rev = rev * 10 + rem;
number = number / 10;
}
if (copy == rev) {
System.out.println("Pali = " + copy);
}
}
}
0 comments:
Post a Comment