FAQ: Learn Python - Practice Makes Perfect - factorial FAQ: Learn Python - Practice Makes Perfect - is_prime

faq

#22

what is false about my code:

def is_prime(x):
for e in x:
while e==range(2,x-1):
if e % n==0:
return False
else:
return True
print is_prime(17)
print is_prime(4)
print is_prime(1)


#23

If x is a number, it is not iterable. Consider, do we need nested loops to solve this problem?