GeetCode Hub

Find the smallest prime palindrome greater than or equal to n.

Recall that a number is prime if it's only divisors are 1 and itself, and it is greater than 1. 

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

Recall that a number is a palindrome if it reads the same from left to right as it does from right to left. 

For example, 12321 is a palindrome.

 

Example 1:

Input: n = 6
Output: 7

Example 2:

Input: n = 8
Output: 11

Example 3:

Input: n = 13
Output: 101

 

Note:

  • 1 <= n <= 108
  • The answer is guaranteed to exist and be less than 2 * 108.

class Solution { public int primePalindrome(int n) { } }