Generation

generate functionSat, 12 Nov 2022

List all the prime numbers

def get_prime_numbers(max_number): numbers = list(range(max_number + 1)) for i in range(2, max_number + 1): if numbers[i]: for j in range(i * i, max_number + 1, i): numbers[j] = False return [i for i in numbers[2:] if numbers[i]] get_prime_numbers(50)

Questions about programming?Chat with your personal AI assistant