Anderson Pozo

Generation

generate functionSat, 24 Jun 2023

Dada una lista de 10 números enteros. Calcular e informar el primer número par, el primer número primo.

def first_even(numbers): for number in numbers: if number % 2 == 0: return number def first_prime(numbers): for number in numbers: if is_prime(number): return number def is_prime(number): if number < 2: return False for i in range(2, number - 1): if number % i == 0: return False return True first_even([1, 2, 3, 4, 5]) first_prime([1, 2, 3, 4, 5])

Questions about programming?Chat with your personal AI assistant