This simple isprime(number) function checks if the given integer number is a prime number and returns True or False. The function makes sure that the number is a positive integer, and that 1 is not considered a prime number.
To find out if an integer n is odd one can use n & 1
, to check for even one can then use not n & 1
or the more traditional n % 2 == 0
which is about 30% slower.