Skip to content

Instantly share code, notes, and snippets.

@Kwpolska
Created January 28, 2013 18:08
Show Gist options
  • Save Kwpolska/4657709 to your computer and use it in GitHub Desktop.
Save Kwpolska/4657709 to your computer and use it in GitHub Desktop.
Python prime number test
# 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