How could I accurately estimate the value of upper_limit in this function, which finds the smallest of the first n consecutive integers to have k distinct prime factors each?
def distinct_primes_factors(limit, num_integers, num_factors):
upper_limit = limit + num_factors
factor_counts = [0] * upper_limit
sequence_count = 0
for num in range(2, upper_limit):
if factor_counts[num] == num_integers:
sequence_count += 1
if sequence_count == num_factors:
return num - num_factors + 1
else:
sequence_count = 0
if factor_counts[num] == 0:
factor_counts[num :: num] = [count + 1 for count in factor_counts[num :: num]]```