Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Prime Palindrome

XPChallenge Points: 20
levelLevel: Medium

Given an integer n, return the smallest number that is both prime and a palindrome and is greater than or equal to n.


• A prime number has exactly two divisors: 1 and itself.
Examples: 2, 3, 5, 7, 11.


• A palindrome reads the same forwards and backwards.
Examples: 121, 1331.


The answer will always exist within the range [2, 2 * 10^8].

 

Example 1:

Input: n = 6

Output: 7

Explanation:

The next prime palindrome after 6 is 7.

Example 2:

Input: n = 8

Output: 11

Explanation:

The next prime palindrome after 8 is 11.

Example 3:

Input: n = 13

Output: 101

Explanation:

The next prime palindrome after 13 is 101.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result