Пример #1
0
from math import sqrt
from common import  prime_table, Watch

Watch.start()
lim = 10000
prime_t = prime_table(lim)
primes = [p for p in range(2, lim) if prime_t[p]]
for odd in range(9, lim, 2):
    if not prime_t[odd]:
        i, found = 0, False
        while primes[i] < odd:
            if sqrt((odd - primes[i]) / 2) % 1 == 0:
                found = True
                break
            i += 1
        if not found:
            print(odd)
            break
Watch.stop()

  
Пример #2
0
from common import Watch, prime_table


Watch.start()
lim, r = 200000, 4
factors, prime_t, criteria = [0] * (lim + 1), prime_table(1000), [r] * r
primes = [i for i in range(1000) if prime_t[i]]
for prime in primes:
    for k in range(2 * prime, lim + 1, prime):
        factors[k] += 1
for i in range(lim - r):
    if factors[i:i + r] == criteria:
        print(i)
        break
Watch.stop()