A palindromic prime is a prime number that can reads the same even if you reverse the digits, e.g. 11, 101, 121, 383, 3443. I want to write a program that asks the user for two numbers, a and b, the program must recursively find all the palindromic primes between a and b and print them out.
I have a function, palindrome, that can recursively reverse the prime after you turn it into a string. I am struggling to create a recursive function that checks if a number is a prime and palindromic as well, it must also save these values and print them out.
def palindrome(seq):
if seq == '':
return seq
else:
return palindrome_reverse(seq[1:]) + seq[0]
This is the expected output of the program:
Enter first number: 50
Enter second number: 150
The palindromic primes between 50 and 150 are:
101
121
131