The primality test returns 1 for integer arguments less than 2.
The current Python logic for checking if a number is prime (1 if all(a % k for k in range(2, a)) else 0) returns incorrect results for integers less than 2. This is because for integer a < 2, range(2, a) is an empty list, so the all gets no values to check, making it evaluate to True, so the ternary if statement chooses the 1, because True is truthy. Therefore, whenever "p" is called with an integer argument less than 2, 1 is pushed onto the stack, wrongly indicating that it's prime. I'd recommend putting an a < 2 check to make it work properly with all integers.
The primality test returns 1 for integer arguments less than 2.
The current Python logic for checking if a number is prime (1 if all(a % k for k in range(2, a)) else 0) returns incorrect results for integers less than 2. This is because for integer a < 2, range(2, a) is an empty list, so the all gets no values to check, making it evaluate to True, so the ternary if statement chooses the 1, because True is truthy. Therefore, whenever "p" is called with an integer argument less than 2, 1 is pushed onto the stack, wrongly indicating that it's prime. I'd recommend putting an a < 2 check to make it work properly with all integers.