1class Solution:2def isPrime(self, num):3from math import sqrt45if num < 2 or num % 2 == 0:6return num == 27for i in range(3, int(sqrt(num)) + 1, 2):8if num % i == 0:9return False10return True1112def primePalindrome(self, n: int) -> int:13if 8 <= n <= 11:14return 1115if len(str(n)) % 2 == 0:16limit = pow(10, len(str(n)) // 2)17else:18n_string = str(n)19limit = n_string[: len(str(n)) // 2 + 1]20for i in range(int(limit), 20000):21y = int(str(i) + str(i)[:-1][::-1])22if y >= n and self.isPrime(y):23return y