Java while loop find palindrome product
public class Main { public static void main(String[] args) { int end = 9999; long max = 0; for (int i = end; i >= 0; i--) { for (int j = end; j >= 0; j--) { long product = i * j; if (product == reverse(product) && product > max) { max = product;//from w w w. jav a 2s . c om } } } System.out.println(max); } public static long reverse(long n) { long reverse = 0; while (n != 0) { long lastDigit = n % 10; reverse = reverse * 10 + lastDigit; n /= 10; } return reverse; } }