def test_check(): P = Prime() primes = [11, 31, 6857] not_primes = [22, 693] for p in primes: assert P.check(p) for p in not_primes: assert not P.check(p)
def p12(n: int): P = Prime() i = 0 while True: i += 1 x = triangle_number(i) divs = divisors(x) xx = len(divs) if xx >= n: print(x) return x
def p5(n: int): # What is the smallest positive number # that is evenly divisible # by all of the numbers from 1 to n ? P = Prime() divisors = list(map(P.factorize, range(2, n))) x = Multiset() for _ in divisors: x = x.union(_) x = np.prod(x) print(x) return x
def p7(n: int): P = Prime() P.find_primes(lambda x: len(P.primes) >= n) print(P.sorted_primes[-10:]) return P.sorted_primes[-1]
def p3(n: int): P = Prime() res = P.factorize(n) print(res) return max(res)
def p10(n: int): P = Prime() P.find_primes(lambda x: x.limit >= n) res = sum(P.primes) print(res) return res
def test_factorize(): P = Prime() y = P.factorize(600851475143) print(y)