Prime number. In a natural number greater than 1, except for 1 and the integer itself, it cannot be divisible by other natural numbers. Prime numbers play an important role in number theory. A number larger than 1 but not a prime number is called a union number. 1 and 0 are both non-prime numbers and non-composite numbers. Prime numbers are two concepts that are opposite to Union numbers. They constitute one of the most basic definitions in number theory. The problems created based on the definition of prime numbers have many world-class problems, such as the godebach conjecture. The basic arithmetic theorem proves that each positive integer greater than 1 can be written as the product of a prime number, and the product form is unique. The important point of this theorem is that 1 is excluded from the prime number set. If 1 is considered as a prime number, these strict interpretations have to add some restrictions. A friend occasionally asked python how to determine the prime number, checked it online, and summarized several methods for the python script to determine whether a number is a prime number: # Use the python mathematical function import math def isPrime (n): if n <= 1: return False for I in range (2, int (math. sqrt (n) + 1): if n % I = 0: return False return True # A single-line program scans prime numbers from math import sqrt N = 100 [p for p in range (2, N) if 0 not in [p % d for d in range (2, int (sqrt (p) + 1)] # Use the itertools module of python from itertools import count def isPrime (n): www.2cto.com if n <= 1: return False for I in count (2): if I * I> n: return True if n % I = 0: return False # Do not use the two methods of the module def isPrime (n): if n <= 1: return False I = 2 while I * I <= n: if n % I = 0: return False I + = 1 return True def isPrime (n ): if n <= 1: return False if n = 2: return True if n % 2 = 0: return False I = 3 while I * I <= n: if n % I = 0: return False I + = 2 return True