<p>Given an integer n, return <em>the smallest <strong>prime palindrome</strong> greater than or equal to </em><code>n</code>.</p>

<p>An integer is <strong>prime</strong> if it has exactly two divisors: <code>1</code> and itself. Note that <code>1</code> is not a prime number.</p>

<ul>
	<li>For example, <code>2</code>, <code>3</code>, <code>5</code>, <code>7</code>, <code>11</code>, and <code>13</code> are all primes.</li>
</ul>

<p>An integer is a <strong>palindrome</strong> if it reads the same from left to right as it does from right to left.</p>

<ul>
	<li>For example, <code>101</code> and <code>12321</code> are palindromes.</li>
</ul>

<p>The test cases are generated so that the answer always exists and is in the range <code>[2, 2 * 10<sup>8</sup>]</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> n = 6
<strong>Output:</strong> 7
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> n = 8
<strong>Output:</strong> 11
</pre><p><strong class="example">Example 3:</strong></p>
<pre><strong>Input:</strong> n = 13
<strong>Output:</strong> 101
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= n &lt;= 10<sup>8</sup></code></li>
</ul>

class Solution {
public:
    // int primePalindrome(int n) {
    //     if(n<8){
    //         for(int i = n; i<8 ; i++){
    //             if(isPrime(i)){
    //                 return i;
    //                 break;
    //             }
    //         }
    //     }else{
    //         for(int j = n; j <=2*100000000; j++ ){
    //             if(isPalindrom(j) && isPrime(j)){
    //                 return j;
    //                 break;
    //             }
    //         }
    //     }  
    //     return 0;    
    // }
    // bool isPrime(int x){
    //     if(x<2){
    //         return false;
    //     }
    //     if(x == 2 || x == 3){
    //         return true;
    //     }
    //     if(x % 2 == 0){
    //         return false;
    //     }
    //     for(int i = 3; i<= sqrt(x); i += 2){
    //         if(x % i == 0){
    //             return false;
    //         }
    //     }
    //     return true;
    // }


    // bool isPalindrom(int x){
    //     int oreginal = x;
    //     int res = 0;
    //     while(x>0){
    //         int digit = x % 10;
    //         res = res*10 + digit;
    //         x /= 10;
    //     }

    //     if(oreginal == res){
    //         return true;
    //     }

    //     return false;

    // }

        int primePalindrome(int N) {
        if (8 <= N && N <= 11) return 11;
        for (int x = 1; x < 100000; ++x) {
            string s = to_string(x), r(s.rbegin(), s.rend());
            int y = stoi(s + r.substr(1));
            if (y >= N && isPrime(y)) return y;
        }
        return -1;
    }
    bool isPrime(int num) {
        if (num < 2 || num % 2 == 0) return num == 2;
        for (int i = 3; i * i <= num; i += 2)
            if (num % i == 0) return false;
        return true;
    }
};
11800