def totient(x): t = x for (k,l) in factorGen(x): t -= t // k return t
''' n_list_mult = [2,3,5,7,11,13] n_list_mult = [1] for i in n_list_mult: n_list.append(i*2*3*5*7*11*13) ''' #for i in xrange(len(p_list)): for n in n_list: #looking for a fraction less than 15499/94744 #once we find the fraction, look for the true lowest denom in the range all_p_list = list(primes(n)) #get divisors for prod div_list = [a for (a,b) in factorGen(n)] #print div_list #create list of resilient fractions based on primes (to the power of 1 only): #does not include divisors of n #must be less than n p_list = [] for p in all_p_list: if p >= n: break if not p in div_list: p_list.append(p) all_list=[] new_list = p_list while len(new_list)>0: last_list = new_list
for n in range(4, total + 1): # for each calculation of L_sub[n], iterate through all divisors of n # for each divisor, get the prime factor decomposition (pfd) st. L_sub[divisor] = p1**a1 * .. * pn**an # for each prime, p get the max value a, s.t. a = max(a_divisor1, ..., a_divisor_n) # if n+1 is prime, then include (n+1)**1 in the pdf for L_sub[n] divisors = list(divisorGen(n)) # aggregate the prime fact decomps of the max_pfd for each divisor # merge like primes by keeping the max value for a p_list = [] for i in divisors: if i != 1 and i != n: print i, Lsub_list[i] for p_a in factorGen(Lsub_list[i]): if not p_a[0] in p_list: p_list.append(p_a[0]) # print p_list # print a_list # check if any primes further divide n # also we calc Lsub[n] by iteratively multiplying by p**a as we determine the max power for a Lsub_list_next = 1 for i in xrange(len(p_list)): # we know p**a divides n # check if p**(a+1) divides n # or just find b s.t. p**b divides (n/ p**a), so then max power is a+b if p_list[i] == 2: if n % 4 == 0: a = 2 + int(math.log(n, 2))