from math import sqrt, log10 def isp(x): if x == 2: return True if x <= 1 or x & 1 == 0: return False for i in xrange(3, int(sqrt(x)) + 1, 2): if x % i == 0: return False return True def ananum(x): if isp(x): for i in xrange(1, int(log10(x)) + 1): if isp(x / (10 ** i)) and isp(x % (10 ** i)): continue else: return False return True return False count = 0 total = [] n = 11 while count < 11: if ananum(n): count += 1 total.append(n) n += 1 print count, sum(total) print total