import math def isPrime(n): if n<=1: return False if n==2 or n==3: return True if n%2==0:#偶数false return False for i in range(3,int(math.sqrt(n))+1,2):#奇数,是否能被<=sqrt(n)的数整除 if n%i==0:#能整除,false return False return True
import math def isPrime(n): if n<=1: return False if n==2 or n==3: return True if n%2==0:#偶数false return False for i in range(3,int(math.sqrt(n))+1,2):#奇数,是否能被<=sqrt(n)的数整除 if n%i==0:#能整除,false return False return True