# coding: utf-8 import math def sum_digits(n): sum = 0 while n > 0: sum += n % 10 n = int(n / 10) return sum def is_prime(n): if n % 2 == 0 and n > 2: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True def next_prime(n): if n % 2 == 0: n += 1 else: n += 2 while not is_prime(n): n += 2 return n a = next_prime(1000000) while not is_prime(sum_digits(a)): a = next_prime(a) b = next_prime(a) while not is_prime(sum_digits(b)): b = next_prime(b) print(str(a) + str(b))