Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Latest commit

 

History

History

0866.prime-palindrome

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

题目

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

Recall that anumber 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 areprimes.

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: 6
Output: 7

Example 2:

Input: 8
Output: 11

Example 3:

Input: 13
Output: 101

Note:

  1. 1 <= N <= 10^8
  2. The answer is guaranteed to exist and be less than 2 * 10^8.

解题思路

见程序注释