Working on the is_prime excercise, and can't seem to get the hang of this one. I looked around and everyone else's examples use a FOR loop. If that's the only way to do it, then I'll re-write, but I started this with a WHILE loop, and I'd rather understand than just copy..
I am getting "Oops, try again. Your function fails on is_prime(5). It returns False when it should return True."
Can anyone help me out, or at least point me in the right direction?
def is_prime(x): if x < 2: return False else: if x == 2 or x == 3: return True y = x - 1 p = 1 while x > 0: p = x / y if p - int(p) == 0: return False break else: y = y - 1 else: return True