I am wondering about the logic in the more common solution for this problem using for n in range(2,(x-1)):
Am I correct in thinking that the logic in this is to save from the other if statements of catching when x is ==2? And that it does not check 1 number away from the max of input through then on out. Such as if the input is 10 it will not check against 10%9 but it doesn't need to because we know that after 2 a number ,say y%(y-1), will never equal 0?
def is_prime_again(x): if x>2: for n in range(2,x): print "" print x print n print x%n print range(2,x) if x%n ==0: print "not prime" return False break return True elif x==2: print "2 is prime" return True else: print "1 and less are not prime" return False print is_prime_again(10)