def circular(n): """ Returns whether or not n is a circular prime """ if not isPrime(n): return False digits = map(int, list(str(n))) for p in rotations(digits): intp = int("".join(map(str, p))) if not isPrime(intp): return False return True
def func(): mx = (0, 0,0) for a in range(-1000, 1000): print "a", a for b in range(1, 1000, 2): if not isPrime(b): continue if lcd(abs(a),abs(b)) < mx[0]: continue f = lambda x: x**2 + a*x + b for n in range(100000): if not isPrime(f(n)): break if n > mx[0]: print "new max:", n mx = (n, a, b) print "mx:", mx print mx[1] * mx[2]
def isRightTruncatable(n): while True: if not isPrime(n): return False n = str(n)[:-1] if len(n) == 0: break n = int(n) return True