content: class Solution {
      public int primePalindrome(int N) {
          for (int L = 1; L <= 5; ++L) {
              //Check for odd-length palindromes
              for (int root = (int)Math.pow(10, L - 1); root < (int)Math.pow(10, L); ++root) {
                  StringBuilder sb = new StringBuilder(Integer.toString(root));
                  for (int k = L-2; k >= 0; --k)
                      sb.append(sb.charAt(k));
                  int x = Integer.valueOf(sb.toString());
                  if (x >= N && isPrime(x))
                      return x;
                      //If we didn't check for even-length palindromes:
                      //return N <= 11 ? min(x, 11) : x
              }
  
              //Check for even-length palindromes
              for (int root = (int)Math.pow(10, L - 1); root < (int)Math.pow(10, L); ++root) {
                  StringBuilder sb = new StringBuilder(Integer.toString(root));
                  for (int k = L-1; k >= 0; --k)
                      sb.append(sb.charAt(k));
                  int x = Integer.valueOf(sb.toString());
                  if (x >= N && isPrime(x))
                      return x;
              }
          }
  
          throw null;
      }
  
      public boolean isPrime(int N) {
          if (N < 2) return false;
          int R = (int) Math.sqrt(N);
          for (int d = 2; d <= R; ++d)
              if (N % d == 0) return false;
          return true;
      }
  }