All problems
Prime Palindrome
Problem
Return the smallest prime number that is also a palindrome and is greater than or equal to n.
Check each candidate for palindromic form and primality, testing divisibility up to the square root. Numbers below 2 are not prime; assume n >= 1.
Hint
Every even-length palindrome greater than 11 is divisible by 11.
Test cases
case 1
in: [1]
expected: 2
case 2
in: [6]
expected: 7
case 3
in: [8]
expected: 11
case 4
in: [13]
expected: 101
case 5
in: [100]
expected: 101
Starter codePython
def prime_palindrome(n):
# Your code here
pass5 test cases · run your code against them in the editor