def gen_primes_con(k): """Only yield if prime p = k mod 4""" i = 1 while True: if i % 4 == k and analyze.pprime(i): yield i i += 1
def init_primes(): for i in xrange(3, MAX, 2): if analyze.pprime(i): if i % 4 == 1: gPrimes1.append(i) else: gPrimes3.append(i)
def get_in_range(length): numbers = [] for i in range(1, length + 1): numbers.append(i) for perm in permutations(numbers): joined = ''.join([str(x) for x in perm]) if pprime(int(joined)): yield joined
def is_goldbach(num): for tsquare in gen_tsquare(): if tsquare > num: break if pprime(num - tsquare): return True else: return False
def next_sexy_foursome(begin): n = begin done = False while not done: tests = [n - 9, n - 3, n + 3, n + 9] for test in tests: if not pprime(test): n += 1 break else: done = True if done: new_tests = [n - 7, n - 5, n - 1, n + 1, n + 5, n + 7] for test in new_tests: if pprime(test): done = False n += 1 break return n
def gen_primes(n): for i in range(1, n, 2): if analyze.pprime(i): yield i
from analyze import pprime def gen_tsquare(): i = 1 while True: yield 2 * (i ** 2) i += 1 def is_goldbach(num): for tsquare in gen_tsquare(): if tsquare > num: break if pprime(num - tsquare): return True else: return False if __name__ == '__main__': i = 3 while True: if not pprime(i) and not is_goldbach(i): print i break i += 2