Created
January 21, 2015 13:20
-
-
Save CesarNog/c72b2dc69423d4e750c0 to your computer and use it in GitHub Desktop.
A prime number is a positive integer greater than 1 that has no positive divisors other than 1 and itself. (Boy, that's a mouthful.) In other words, if you want to test if a number in a variable x is prime, then no other number should go into x evenly besides 1 and x. So 2 and 5 and 11 are all prime, but 4 and 18 and 21 are not. If there is a nu…
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
def is_prime(x): | |
if x < 2: | |
return False | |
elif x == 2: | |
return True | |
else: | |
for n in range(2, x): | |
print n | |
if x % n == 0: | |
return False | |
else: | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you