Solution
C++ []\nclass Solution {\n    bool isPrime(int val){\n        if(val == 1 ) \n            return false ;\n        if(val == 2)\n            return true ;\n     
```C++ []\nclass Solution {\n    bool isPrime(int val){\n        if(val == 1 ) \n            return false ;\n        if(val == 2)\n            return true ;\n        int limit = sqrt(val) ;\n        for(int i = 2; i <= limit; i++){\n            if(val % i == 0)\n                return false ;\n        }\n        return true ;\n    }\npublic:\n    int primePalindrome(int n) {\n        if(n >= 8  && n <= 11)\n            return 11 ;\n        for(int i = 1; i <= 1e5; i++){\n            string s = to_string(i) ;\n            string t(s.rbegin(), s.rend()) ;\n            int val = stoi(s + t.substr(1)) ;\n            if(val >= n && isPrime(val))\n                return val ;\n        }\n        return -1 ;\n    }\n};\n```\n\n```Python3 []\nclass Solution:\n    def isPrime(self, num):\n        from math import sqrt\n        if num < 2 or num % 2 == 0:\n            return num == 2\n        for i in range(3, int(sqrt(num)) + 1, 2):\n            if num % i == 0:\n                return False\n        return True\n\n    def primePalindrome(self, n: int) -> int:\n        if 8 <= n <= 11:\n            return 11\n        if len(str(n)) % 2 == 0:\n            limit = pow(10, len(str(n)) // 2)\n        else:\n            n_string = str(n)\n            limit = n_string[:len(str(n)) // 2 + 1]\n        for i in range(int(limit), 20000):\n            y = int(str(i) + str(i)[:-1][::-1])\n            if y >= n and self.isPrime(y):\n                return y\n```\n\n```Java []\nclass Solution {\n    private int n;\n    private int numDigits;\n    private static ArrayList<Integer> primes;\n    private static int lastChecked = 1;\n    public int primePalindrome(int nInput) {\n        n = nInput;\n        if (n==1 || n==2){\n            return 2;\n        }\n        if (n==4 || n==5){\n            return 5;\n        }\n        if (primes == null){\n            primes = new ArrayList<Integer>();\n            primes.add(2);\n        }\n        numDigits = 1;\n        while (n >= Math.pow(10, numDigits)){\n            numDigits++;\n        }\n        if (numDigits%2 == 0 && n > 11){\n            n = (int)Math.pow(10, numDigits)+1;\n            numDigits++;\n        }\n        int msd = getDigit(numDigits);\n        if (msd%2 == 0 || msd == 5){\n            if (msd >= 4 && msd <= 6){\n                msd = 7;\n            } else {\n                msd++;\n            }\n            n = msd;\n            if (numDigits!=1){\n                n+=msd * (int)Math.pow(10, numDigits-1);\n            }\n        } else {\n            for (int i = (numDigits+1)/2; i > 0; i--){\n                setDigit(i, getDigit(numDigits-i+1));\n            }\n            if (n < nInput){\n                increment();\n            }\n        }\n        while (!isPrime()){\n            increment();\n        }\n        return n;\n    }\n    private int getDigit(int i) {\n        return (n%(int)Math.pow(10, i))/(int)Math.pow(10, i-1);\n    }\n    private void setDigit(int i, int m) {\n        int first = n-n%(int)Math.pow(10, numDigits-i+1);\n        int middle = Math.max(0, n%(int)Math.pow(10, numDigits-i)\n            - n%(int)Math.pow(10, i));\n        int last = n%(int)Math.pow(10, i-1);\n        n = first + middle + last + m*(int)Math.pow(10, i-1);\n        if (i != numDigits-i+1){\n            n += m*(int)Math.pow(10, numDigits-i);\n        }\n    }\n    private void increment(){\n        for (int i = (numDigits+1)/2; i > 0; i--){\n            int curDigit = getDigit(i);\n            if (i == 1 && curDigit == 9){\n                if (numDigits == 1){\n                    n = 11;\n                    numDigits = 2;\n                    return;\n                } else {\n                    n = (int)Math.pow(10, numDigits+1)+1;\n                    numDigits+=2;\n                    return;\n                }\n            } else if (curDigit == 9){\n                setDigit(i, 0);\n            } else {\n                curDigit++;\n                if (i == 1){\n                    if (curDigit%2 == 0 || curDigit == 5){\n                        if (curDigit >= 4 && curDigit <= 6){\n                            curDigit = 7;\n                        } else {\n                            curDigit++;\n                        }\n                    }\n                }\n                setDigit(i, curDigit);\n                return;\n            }\n        }\n    }\n    private boolean isPrime() {\n        int end = (int)Math.sqrt(n);\n        for (int i = lastChecked+2; i <= end; i+=2){\n            if (isPrimeLookup(i)){\n                primes.add(i);\n            }\n            lastChecked = i;\n        }\n        return isPrimeLookup(n);\n    }\n    private boolean isPrimeLookup(int m){\n        int end = (int)Math.sqrt(m);\n        for (int i = 0; i < primes.size() && primes.get(i) <= end; i++){\n            if (m%primes.get(i) == 0){\n                return false;\n            }\n        }\n        return true;\n    }\n}\n```\n
['C++', 'Java', 'Python3']