#๐Ÿ”’ Limit for finding the smallest of the first n consecutive integers to have k distinct prime factor

4 messages ยท Page 1 of 1 (latest)

hardy bolt
#

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]]```
topaz quarryBOT
#

@hardy bolt

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

topaz quarryBOT
#

@hardy bolt

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.