TheOnlinePhotographer has published a post to celebrate 171717 comments and was amused by the number’s symmetry.

A great comment by Lynn pointed out that this number is indeed an interesting number but not symmetrical.

Symmetrical numbers or words *–* also called palindromes *–* are defined as being the same read forwards or backwards. Examples for palindromic words are *radar*, *noon* or *level*. Palindromic numbers are *3*, *404* or *172271*.

Lynn then went further and checked if 171717 is at least a prime. The number sadly has five distinct prime factors .

So Lynn wondered what the next palindromic prime would be.

To answer this question, I wrote this little Python program to check for palindromic primes. The first 120 palindromic primes are shown below.

Based on this list, the smallest palindromic prime larger than 171717 is __ 1003001__.

3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929, 10301, 10501, 10601, 11311, 11411, 12421, 12721, 12821, 13331, 13831, 13931, 14341, 14741, 15451, 15551, 16061, 16361, 16561, 16661, 17471, 17971, 18181, 18481, 19391, 19891, 19991, 30103, 30203, 30403, 30703, 30803, 31013, 31513, 32323, 32423, 33533, 34543, 34843, 35053, 35153, 35353, 35753, 36263, 36563, 37273, 37573, 38083, 38183, 38783, 39293, 70207, 70507, 70607, 71317, 71917, 72227, 72727, 73037, 73237, 73637, 74047, 74747, 75557, 76367, 76667, 77377, 77477, 77977, 78487, 78787, 78887, 79397, 79697, 79997, 90709, 91019, 93139, 93239, 93739, 94049, 94349, 94649, 94849, 94949, 95959, 96269, 96469, 96769, 97379, 97579, 97879, 98389,,98689,1003001, 1022201, 1028201, 1035301, 1043401, 1055501, 1062601, ...1008001

Thus it takes more comments to reach the closest palindromic prime.

The sequence of palindromic primes is number A002385 in the On-line Encyclopedia of Integer Sequences (OEIS).

```
# Python 2.7.7 Code
# Jonathan Frech 23rd of March, 2016
```

```
# checks if n is prime or not
def prime(n):
if n <= 1:
return False
for _ in range(2, n):
if n % _ == 0:
return False
return True
# list and length of generated sequence
L = []
N = 120
n = 1
while len(L) < N:
# check if n is a palindromic prime
if str(n) == str(n)[::-1] and prime(n):
# new palindromic prime!
L.append(n)
# progress update
print str(100. * len(L) / N) + "%"
# increment n
n += 2
# printout
print L
```