generate functionThu, 02 Mar 2023

Given a natural number N. Determine if it is prime. A natural number N is called prime if it has only two divisors: one and the number N itself. As an answer, print "Yes" if the number is prime, "No" otherwise.

def is_prime(n): if n < 2: return False for i in range(2, n): if n % i == 0: return False return True is_prime(7)

Questions about programming?Chat with your personal AI assistant