def solve(D): primes = sieve_eratosthenes(D) factorizations = list(factorizations_below(D, primes)) assert len(factorizations)+1 == D return sum([phi_of_factorization(factorization) for factorization in factorizations])
def solve(D, i): primes = sieve_eratosthenes(D) l = list(factorizations_below(D, primes)) + [((1,1),)] E = sorted([(num(factors), rad(factors)) for factors in l], cmp_rad) return E[i-1][0]