def problem49(): for i in range(1000, 10000): # Building list of prime and non-prime nums helper.is_prime_num(i) prime_nums = list(helper.get_prime_nums()) prime_nums.sort() answer = [] for i in range(len(prime_nums)): for j in range(i + 1, len(prime_nums)): num = prime_nums[j] + prime_nums[j] - prime_nums[i] if num in prime_nums: correct = True for k in range(0, 9): digit = str(k) if str(prime_nums[j]).count(digit) != str(prime_nums[i]).count(digit) or str(prime_nums[j]).count(digit) != str(num).count(digit): correct = False if correct: answer.append(str(prime_nums[i]) + str(prime_nums[j]) + str(num)) return answer
def problem5b(factors): use = [] factors.sort() for i in range(1, len(factors)): if helper.is_prime_num(factors[i]): use.append(factors[i]) elif helper.multiple_of_factors(use, factors[i]): use.append(factors[i]) answer = 1 print (use) for i in use: answer *= i return answer
def problem27(limit): max = 0 a_max = 0 b_max = 0 for a in range(-1*limit, limit + 1): for b in range(-1*limit, limit + 1): n = 0 while helper.is_prime_num((n*n + a*n + b)): n += 1 if n > max: max = n a_max = a b_max = b return (a_max * b_max)
def problem10(upperbound): summation = 0 for i in range(upperbound): if helper.is_prime_num(i): summation += i return summation