public static boolean isPalindrome(int x) {
        int size = 1;
        while (size <= 9) {
            int pow = (int)(Math.pow(10, size));
            if ((int)(x/pow) == 0) {
                break;
            }
            else {
                size++;
            }
        }

        while (size > 0) {
            int tail = x % 10;
            int pow = (int)(Math.pow(10, size - 1)); 
            int head = (int) (x / pow);
            if (head != tail) {
                return false;
            }
            size -= 2;
            x = (int)(x % pow);
            x = (int)(x / 10);
        }
        return true;
    }