Last active
August 29, 2015 14:20
-
-
Save sincerefly/cafd4e727c2b6885e5d4 to your computer and use it in GitHub Desktop.
python判断素数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment