def is_prime(x): i=0 if x==0 or x==1: return False elif x==2 or x==3: return True else: for n in range(2, x-1): if x % n != 0: i+=1 if x-2==i: return True else: return False
my code above works this way:
I defined a counter named "i", it counts the number of remainders. as a Prime number we must have remainder in each division from 2 up to the number (except itself). so the number of remainder must be "number-2".
this is how I wrote my algorithm and I don't know why it gets an error! the error says :
Oops, try again. Your function fails on is_prime(5). It returns False when it should return True.
Any help would be appreciated