Created
December 30, 2014 06:08
-
-
Save usmanity/e2113fc5175afe2e6a5b to your computer and use it in GitHub Desktop.
prime in python
This file contains hidden or 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
# http://stackoverflow.com/questions/18833759/python-prime-number-checker | |
import math | |
def is_prime(n): | |
if n % 2 == 0 and n > 2: | |
return False | |
return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment