def is_goldback_composite(i): primes = my_module.generate_prime(2, i) squares = [] for n in range(1, int(math.ceil(math.sqrt(i)))+1): squares.append(2 * (n ** 2)) for prime in primes: for square in squares: if prime + square == i: return(True) return(False)
import my_module number = 600851475143 primes = my_module.generate_prime(2, 10000) prime_factors = [] for i in primes: if number % i == 0: prime_factors.append(i) print max(prime_factors)
import my_module sum_of_primes = 0 for i in my_module.generate_prime(2, 2000000): sum_of_primes += i print sum_of_primes
def test_generate_prime(self): self.assertEqual(my_module.generate_prime(2, 11), [2, 3, 5, 7])
families.append(family) return(families) def getfamilymembers(n): families = getfamilies(n) familymembers = [] for i in families: family = [] for x in range(1, 10): member = [] for digit in i: if digit == "*": member.append(str(x)) else: member.append(digit) family.append("".join(member)) familymembers.append(family) return(familymembers) primes = (my_module.generate_prime(10, 130000)) for i in primes: for family in getfamilymembers(str(i)): count = 0 for n in family: if my_module.is_prime(int(n)): count += 1 if count == 8: print(min(family)) sys.exit()