I don't understand how the code is working for 2? 2 is divisible by both 2 and 1. so x%n is equal to zero in both cases. That should return False, but it is returning True
The code is working. And I know 2 is a prime number. I am just trying to figure out, how it is working for 2?
def is_prime(x): if x<2: return False for n in range (2,x): if x%n==0: return False else: return True print(is_prime(2))