Created
January 28, 2013 18:08
-
-
Save Kwpolska/4657709 to your computer and use it in GitHub Desktop.
Python prime number test
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
# A fancy way to test if a number is prime in Python. | |
# Copyright © 2013, Kwpolska. Free for any use if this clause is reproduced. | |
def prime(n): | |
for i in range(2, n): | |
t = float(n) / float(i) # if you need debug, just print t | |
if (t % 1) == 0: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment