def test_primes(primes): lp = len(primes) for i in range(lp): for j in range(i+1, lp): si = str(primes[i]) sj = str(primes[j]) if not et.is_prime(int(si + sj)): return False if not et.is_prime(int(sj + si)): return False return True
def prime_digit_replacement(): primes = et.prime_sieve(9999999)[25:] chars = '0123456789' for p in primes: count = {} for s in str(p): if count.has_key(s): count[s] += 1 else: count[s] = 1 for key in count: if count[key] > 1: not_prime = 0 for c in chars: sp = str(p) np = int(sp.replace(key, c)) if len(str(np)) != len(sp): not_prime += 1 continue if not et.is_prime(np): not_prime += 1 if not_prime > 3: break if not_prime < 3: return p
def is_prime_sequence(n): n2 = n**2 primes = [1, 3, 7, 9, 13, 27] for p in primes: if not euler_tools.is_prime(n2+p): return False return True
def pandigital_prime(): symbols = '1234567' products = set() max_prime = 0 while symbols: current = list(symbols) while increment_last_symbol(current, symbols): while len(current) < len(symbols): append_symbol(current, symbols) if et.is_prime(int(''.join(current))): max_prime = int(''.join(current)) if max_prime > 0: return max_prime symbols = symbols[:-1]
def spiral_primes(): total = 1 current = 1 current_side = 1 prime_count = 0.0 total_count = 1.0 while True: current_side += 2 for j in range(4): current += current_side - 1 if et.is_prime(current): prime_count += 1 total_count += 1 if prime_count / total_count < 0.1: break return current_side