package leetcode;

/**
 * https://leetcode.com/problems/prime-palindrome/
 */
public class Problem866 {
    public int primePalindrome(int N) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem866 prob = new Problem866();
        System.out.println(prob.primePalindrome(6)); // 7
        System.out.println(prob.primePalindrome(8)); // 11
        System.out.println(prob.primePalindrome(13)); // 101
    }
}

@@ -149,24 +149,42 @@
     
-// TODO%0A
+if (8 %3C= N && N %3C= 11) %7B%0A 
         
 retu
@@ -183,291 +183,620 @@
     
+   
 return 
-0;%0A
+11;%0A    
     %7D%0A
-%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem866 prob = new Problem866();%0A        System.out.println(prob.primePalindrome(6)); // 7%0A        System.out.println(prob.primePalindrome(8)); // 11%0A        System.out.println(prob.primePalindrome(13)); // 101
+    for (int x = 1; x %3C 100000; x++) %7B%0A            String s = Integer.toString(x);%0A            String r = new StringBuilder(s).reverse().toString().substring(1);%0A            int y = Integer.parseInt(s + r);%0A            if (y %3E= N && isPrime(y)) %7B%0A                return y;%0A            %7D%0A        %7D%0A        return -1;%0A    %7D%0A%0A    private static boolean isPrime(int n) %7B%0A        if (n %3C 2) %7B%0A            return false;%0A        %7D%0A        for (int i = 2; i %3C= (int) Math.sqrt(n); i++) %7B%0A            if (n %25 i == 0) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;
 %0A   

Solve problem 866