from tools import number_theory def num_factor(num): factor = [] if not num % 2: factor.append(2) while not num % 2: num //= 2 p = 3 while p * p < num: if not num % p: factor.append(p) while not num % p: num //= p p += 2 if 1 < num: factor.append(num) return factor def find(count, a, b): seq = 0 a += 1 while b + seq >= count + a: if len(num_factor(a)) == count: seq += 1 else: seq = 0 if seq == count: return a - count + 1 a += 1 def search(count, limit): prime = list(number_theory.make_prime(limit)) for i in range(len(prime) - 1): get = find(count, prime[i], prime[i + 1]) if get: return get print(search(4, 200000))