A palindromic prime is a prime number that is also palindromic. For example, 131 is a prime and also a palindromic prime, as are 313 and 757.
I need to write a function that displays the first n
palindromic prime numbers.
Display 10 numbers per line and align the numbers properly, as follows:
2 3 5 7 11 101 131 151 181 191
313 353 373 383 727 757 787 797 919 929
my code is:
def paliPrime(n):
a=0
b=n
a+=1
for i in range(a,b):
paliPrime=True
if str(i) == str(i)[::-1]:
if i>2:
for a in range(2,i):
if i%a==0:
paliPrime=False
break
if paliPrime:
print i
the code works but not in the way i wanted:
>>> paliPrime(10)
3
5
7
>>>
And what I want is a function that displays the first n palindromic prime numbers. It should display 10 numbers per line and align the numbers properly.