Given an integer n, return the smallest prime palindrome greater than or equal to n.

An integer is prime if it has exactly two divisors: 1 and itself. Note that 1 is not a prime number.


	For example, 2, 3, 5, 7, 11, and 13 are all primes.


An integer is a palindrome if it reads the same from left to right as it does from right to left.


	For example, 101 and 12321 are palindromes.


The test cases are generated so that the answer always exists and is in the range [2, 2 * 108].

&nbsp;
Example 1:
Input: n = 6
Output: 7
Example 2:
Input: n = 8
Output: 11
Example 3:
Input: n = 13
Output: 101

&nbsp;
Constraints:


	1 &lt;= n &lt;= 108


class Solution:
    def primePalindrome(self, n: int) -> int:
        if n<3:return 2
        #generating palindrome less than 10**8
        l=[""]+[*"1234567890"]
        for i in l:
            if len(i)<7:
                for j in "1234567890":
                    l+=[j+i+j]
        #finding prime from generated palindrome
        q=[]
        for i in l[2:]:
            if i[0]!="0":
                i=int(i)
                t=i%2
                if t:
                    for j in range(3,int(i**.5)+1,2):
                        if i%j==0:
                            t=0
                            break
                if t:q+=[i]
        q.sort()
        q+=[100030001]
        return q[bisect_left(q,n)]
// Prime Palindrome
// Leetcode problem: https://leetcode.com/problems/prime-palindrome/

class Solution {
    public int primePalindrome(int n) {
        while (true) {
            if (isPrime(n) && isPalindrome(n)) {
                return n;
            }
            n++;
        }       
    }
    private boolean isPrime(int n) {
        if (n == 1) {
            return false;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
    private boolean isPalindrome(int n) {
        String s = String.valueOf(n);
        int i = 0;
        int j = s.length() - 1;
        while (i < j) {
            if (s.charAt(i) != s.charAt(j)) {
                return false;
            }
            i++;
            j--;
        }
        return true;
    }
}
class Solution {

public:
    bool isPrime(int N) {
    if (N < 2) return false;
    int R = (int)sqrt(N);
    for (int d = 2; d <= R; ++d)
        if (N % d == 0) return false;
    return true;
    }

public:
    int reverse(int N) {
    int ans = 0;
    while (N > 0) {
        ans = 10 * ans + (N % 10);
           N /= 10;
        }
    return ans;
    }
public:
    int primePalindrome(int n) {
        while (true) {
            if (n == reverse(n) && isPrime(n))
                return n;
            n++;

            // Any even length palindrome must be divisble by 11
            // so we will skip numbers N = [10,000,000, 99,999,999]
            if (10000000 < n && n < 100000000)
                n = 100000000;
        }
    }
};
/**
 * @param {number} n
 * @return {number}
 */
var primePalindrome = function(n) {

    while (true){
        let str = String(n)
        if (String(n).length % 2 == 0 && n > 11){
            n = Math.pow(10, Math.ceil(Math.log10(n+1)))
            // or n = 1 + Array(str.length).fill(0).join("")
            continue
        }
        if (!isPalindrome(str)) {
            n++
            continue
        }
        if (isPrime(n)) return n
        n++
    }

};

function isPrime(n){
    if (n <= 1) return false
    if (n <= 3) return true
    if (n % 2 == 0 || n % 3 == 0) return false

    for (let i = 3; i <= Math.floor(Math.sqrt(n)) + 1;i+=2){
        if (n % i == 0) return false
    }
    return true
}

function isPalindrome(str){
    let l = 0, r = str.length-1
    while (l < r){
        if (str[l] != str[r]) return false
        l++
        r--
    }
    return true
}
Prime Palindrome