def main(): """ The most expensive process (computationally) is the factor calculation. """ found_solution = False i = 1 primes = euler.eratosthenes_sieve(200000) max_factors = 0 while not found_solution: i += 1 num = triangle(i) prime_candidates = [x for x in primes if x <= num] prime_factors = get_prime_factors(num, prime_candidates) all_factors = get_all_factors(num, Set(prime_factors)) if len(all_factors) > max_factors: max_factors = len(all_factors) print "max num factors: %d" % max_factors found_solution = len(all_factors) > 500 print "The first triangle number with more than 500 factors is %d " % num
def main(): """ Compute the list of all primes below 2 millions using the erathostenes sieve and add it up. """ primes = euler.eratosthenes_sieve(2000000) print "The sum of all primes below 2 million is %d " % sum(primes)