def d(n): factors = factor.get_factors(n) am_nums = [] for pair in factors: if n in pair: am_nums.append(1) else: am_nums += pair return sum(am_nums)
def is_abundant(n): if n not in memo_a: factors = factor.get_factors(n) fac_sum = 0 for pair in factors: if n in pair: fac_sum += 1 else: fac_sum += pair[0] if pair[0] != pair[1]: fac_sum += pair[1] memo_a[n] = fac_sum > n return memo_a[n]
#!/usr/bin/env pypy from factor import get_factors primes_found = 0 prime_to_get = 10001 current_prime = 1 while primes_found < prime_to_get - 2: current_prime += 1 if len(get_factors(current_prime)) == 1: primes_found += 1 print(current_prime)
def is_prime(n): return n >= 0 and len(factor.get_factors(n)) == 1
#!/usr/bin/env pypy from factor import get_factors counter = 1 accumulator = 0 max_factors = 0 while max_factors <= 250: accumulator += counter counter += 1 factors = len(get_factors(accumulator)) if factors > max_factors: max_factors = factors print(accumulator)
#!/usr/bin/env pypy from factor import get_factors bound = 2000000 running_sum = 0 for i in xrange(2, bound): if len(get_factors(i)) == 1: running_sum += i if not (i%20000): print(i) print(running_sum)
#!/usr/bin/env pypy from factor import get_factors primes_found = 0 prime_to_get = 10001 current_prime = 1 while primes_found < prime_to_get-2: current_prime += 1 if len(get_factors(current_prime)) == 1: primes_found += 1 print(current_prime)