is_prime 源码
知道给定自然数是否为质数的简单函数 素数定义 A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. (Wikipedia) isPrime()函数 如果给定的自然数为质数,则返回True;否则,则返回False。 def isPrime ( num ): if num < 2 : return None if num == 2 : return True if num % 2 == 0 :
用户评论