def prime_divisors(n): try: return PDS[n] except KeyError: #with euler_tools.Watch('PRIME DIVISORS %s' % n): pds = euler_tools.prime_divisors(n) PDS[n] = pds return pds
def keys(n): dice = sieve(n) p = 1 for m in range(1, n + 1): o = sum([d for d in dice[:m] if d == 1]) if p + 1 == o: print(m, o, euler_tools.prime_divisors(m)) p = o return None
def replace(factorization, factor, limit): _factorization = copy.deepcopy(factorization) for i in range(2, factor): factorization[factor] = 0 pds = euler_tools.prime_divisors(i) for pd in pds: factorization[pd] += 1 print(factor, i, pds, factorization, d(factorization), d(_factorization)) if 2 * limit < d(factorization): return factorization, True else: factorization = copy.deepcopy(_factorization) return _factorization, False
def prime_divisor(i, primes): s = time.time() pds = euler_tools.prime_divisors(i, primes) e = time.time() - s return pds, e
def check_x(x, nds): xds = euler_tools.prime_divisors(x**3 - 1) for nd in nds: if nd not in xds: return False return True
def check(n): for x in check_n(n): print(x, euler_tools.prime_divisors_2(n), euler_tools.prime_divisors(x**3 - 1))
def combin(n, k): return int(fact(n) / (fact(k) * fact(n - k))) def product(x): p = 1 for _x in x: p *= _x return p def num_divisors(num_primes): return 1 + sum([combin(num_primes, n) for n in range(1, num_primes + 1)]) # def pseudo_sqrt(n): # index = len(all_divisors(n))/2-1 print(euler_tools.prime_divisors(3102), 3102**0.5) print(PRIMES, product(PRIMES), product(PRIMES)**0.5) #p = product(PRIMES) #d = euler_tools.all_divisors(p) #print(d, len(d), d.index(42)) print(num_divisors(len(PRIMES)) / 2 - 1)
if x.is_integer() and y.is_integer( ) and p < p_max and not seen[(x, y)]: print(a, b, c, x, y, p, area) triples += p seen[(x, y)] = True else: triples += 0 else: triples += 0 #print(max_p, max_p/p_max) m += 1 return triples N = 5 P = 1e6 #triples = pythag_triples(N, P) #print(triples) print(coprime(516309057, 894260792)) print(coprime(516309057, 1032607092)) print(coprime(894260792, 1032607092)) print(euler_tools.prime_divisors(516309057)) print(euler_tools.prime_divisors(894260792)) print(euler_tools.prime_divisors(1032607092))