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 or n == 3: return "Yes" elif n < 2 or n > 3: for i in range(2, n): if n % i == 0: return "No" return "Yes" else: return "No"

Questions about programming?Chat with your personal AI assistant