Simple Python function to test integer is a prime number


def isprime(n):
 if n == 1:
 print("1 is special")
 return False
 for x in range(2, n):
 if n % x == 0:
 print("{} equals {} x {}".format(n, x, n // x))
 return False
 print(n, "is a prime number")
 return True

Be the first to comment

Leave a Reply

Your email address will not be published.