Class Solution
-
- All Implemented Interfaces:
public final class Solution866 - Prime Palindrome.
Medium
Given an integer n, return the smallest prime palindrome greater than or equal to
n.An integer is prime if it has exactly two divisors:
1and itself. Note that1is not a prime number.For example,
2,3,5,7,11, and13are all primes.
An integer is a palindrome if it reads the same from left to right as it does from right to left.
For example,
101and12321are palindromes.
The test cases are generated so that the answer always exists and is in the range <code>2, 2 * 10<sup>8</sup></code>.
Example 1:
Input: n = 6
Output: 7
Example 2:
Input: n = 8
Output: 11
Example 3:
Input: n = 13
Output: 101
Constraints:
<code>1 <= n <= 10<sup>8</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegerprimePalindrome(Integer n)-
-
Method Detail
-
primePalindrome
final Integer primePalindrome(Integer n)
-
-
-
-