def find_triples(self): """ a = b ** 2 + c ** 3 + d ** 4 b,c,d - primes min a = 4 + 8 + 16 a <= self.limit :return: """ self.triples = set() d_primes = mylib.find_primes_to_limit((self.limit - 12) ** (1 / 4), True) # print(self.limit, d_primes) for d in d_primes: d4 = d ** 4 c_primes = mylib.find_primes_to_limit((self.limit - d4 - 4) ** (1 / 3), True) # print(d, d4, c_primes) for c in c_primes: c3 = c ** 3 b_primes = mylib.find_primes_to_limit((self.limit - d4 - c3) ** (1 / 2), True) # print(d, d4, c, c3, b_primes) for b in b_primes: b2 = b ** 2 a = b2 + c3 + d4 print(a, b, c, d) if a > self.limit: raise AssertionError('WRONG FORMULA!!') self.triples.add(a) return self
def find_triples(self): """ a = b ** 2 + c ** 3 + d ** 4 b,c,d - primes min a = 4 + 8 + 16 a <= self.limit :return: """ self.triples = set() d_primes = mylib.find_primes_to_limit((self.limit - 12)**(1 / 4), True) # print(self.limit, d_primes) for d in d_primes: d4 = d**4 c_primes = mylib.find_primes_to_limit( (self.limit - d4 - 4)**(1 / 3), True) # print(d, d4, c_primes) for c in c_primes: c3 = c**3 b_primes = mylib.find_primes_to_limit( (self.limit - d4 - c3)**(1 / 2), True) # print(d, d4, c, c3, b_primes) for b in b_primes: b2 = b**2 a = b2 + c3 + d4 print(a, b, c, d) if a > self.limit: raise AssertionError('WRONG FORMULA!!') self.triples.add(a) return self
def solve(): a = mylib.find_primes_to_limit(100000000) for x in a: cc = find_chains(x) if len(cc): print(x, cc) return True
def solve(): # a = mylib.find_primes_to_limit(25, True) # a = mylib.find_primes_to_limit(90, True) a = mylib.find_primes_to_limit(3940, True) s = sum(a) print(s, len(a), a) print('-' * 79) sum_all(a) return True
def solve(): # a = mylib.find_primes_to_limit(25, True) # a = mylib.find_primes_to_limit(90, True) a = mylib.find_primes_to_limit(3940, True) s = sum(a) print(s, len(a), a) print ('-' * 79) sum_all(a) return True
while len(aa): aaa = [] for a in aa: c = n * (n + a) + b #print(n, a, b, c) if c > 1 and mylib.is_prime(c): aaa.append(a) if len(aaa): aaaa = aaa aa = aaa n += 1 return [n-1, aaaa] if __name__ == '__main__': bb = mylib.find_primes_to_limit(1000, True) r = {} for b in bb: r[b] = findLongestAForB(b) print(b, r[b][0], r[b][1]) maxC = 0 maxB = 0 maxA = 0 for b in r: if r[b][0] > maxC: maxC = r[b][0] maxB = b maxA = r[b][1] print(maxC, maxA, maxB, maxA[0] * maxB)
aaa = [] for a in aa: c = n * (n + a) + b #print(n, a, b, c) if c > 1 and mylib.is_prime(c): aaa.append(a) if len(aaa): aaaa = aaa aa = aaa n += 1 return [n - 1, aaaa] if __name__ == '__main__': bb = mylib.find_primes_to_limit(1000, True) r = {} for b in bb: r[b] = findLongestAForB(b) print(b, r[b][0], r[b][1]) maxC = 0 maxB = 0 maxA = 0 for b in r: if r[b][0] > maxC: maxC = r[b][0] maxB = b maxA = r[b][1] print(maxC, maxA, maxB, maxA[0] * maxB)