Palindromic Primes

What is the number of palindromic primes p p less than 1 0 5 10^5 ?

Hint: The answer is a prime number.


this problem is a part of set Prime Crimes via Computer Science


The answer is 113.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

David Holcer
Jan 29, 2016
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from math import *
def is_prime(a):
    return a > 1 and all(a % i for i in xrange(2, a))

total=0
c=1
while c<(10**5):
    if ((str(c)==str(c)[::-1]) and (is_prime(c)==True)):
        total+=1
    c+=1
print total

prime checker, then while loop to check conditions, starting with palindrome.

It's good!

Zeeshan Ali - 5 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...