Beispiel #1
0
def findConseqWithProperty(n):
    sieve(10 ** 6)  # initialize the sieve
    conseq = 0

    for candidate in count(1):
        if candidate % 1000 == 0:
            print(candidate)

        if len(primeFactors(candidate)) == n:
            conseq += 1
        else:
            conseq = 0

        if conseq == n:
            print(candidate - n + 1)
            break
Beispiel #2
0
def bruteIt():
    limit = 10000
    s = sieve(limit)
    # Only odds numbers
    for candidate in range(3, limit, 2):
        # Only composite
        if not s[candidate]:
            # Brute : test all the primes smaller than candidate and check the
            # property of the substraction
            isGoldbach = False
            for p in primes(candidate):
                delta = candidate - p
                if (int(math.sqrt(delta/2)) == math.sqrt(delta/2)):
                    isGoldbach = True
                    break

            if not isGoldbach:
                print(candidate)
                break