g0801_0900.s0866_prime_palindrome.readme.md Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java17 Show documentation
Show all versions of leetcode-in-java17 Show documentation
Java Solution for LeetCode algorithm problems, continually updating
866\. 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: `1` and itself. Note that `1` is not a prime number.
* For example, `2`, `3`, `5`, `7`, `11`, and `13` are 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, `101` and `12321` are palindromes.
The test cases are generated so that the answer always exists and is in the range [2, 2 * 108]
.
**Example 1:**
**Input:** n = 6
**Output:** 7
**Example 2:**
**Input:** n = 8
**Output:** 11
**Example 3:**
**Input:** n = 13
**Output:** 101
**Constraints:**
* 1 <= n <= 108