Java program to print palindrome number upto N numbers

By candid | Posted :
11 May, 2016
| Updated :
21 Dec, 2017

Program

public class PalindromeUptoN {

public static void main(String[] args) { int n, b, rev = 0; int limit=50; System.out.print("Palindrome numbers from 1 to N:"); for (int i = 1; i <= limit; i++) { n = i; while (n > 0) { b = n % 10; rev = rev * 10 + b; n = n / 10; } if (rev == i) { System.out.print(i + " "); } rev = 0; }

}

}

Output

Palindrome numbers from 1 to N:1 2 3 4 5 6 7 8 9 11 22 33 44