generate functionTue, 07 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 == 1: print("No") return for k in range(2, N): if N % k == 0: print("No") return print("Yes") is_prime(5) is_prime(4)

Questions about programming?Chat with your personal AI assistant