1
class Solution:
2
def isPrime(self, num):
3
from math import sqrt
4

5
if num < 2 or num % 2 == 0:
6
return num == 2
7
for i in range(3, int(sqrt(num)) + 1, 2):
8
if num % i == 0:
9
return False
10
return True
11

12
def primePalindrome(self, n: int) -> int:
13
if 8 <= n <= 11:
14
return 11
15
if len(str(n)) % 2 == 0:
16
limit = pow(10, len(str(n)) // 2)
17
else:
18
n_string = str(n)
19
limit = n_string[: len(str(n)) // 2 + 1]
20
for i in range(int(limit), 20000):
21
y = int(str(i) + str(i)[:-1][::-1])
22
if y >= n and self.isPrime(y):
23
return y

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0