Skip to content

Instantly share code, notes, and snippets.

@md-mq
Created August 27, 2012 18:58
Show Gist options
  • Select an option

  • Save md-mq/3491343 to your computer and use it in GitHub Desktop.

Select an option

Save md-mq/3491343 to your computer and use it in GitHub Desktop.
finding prime factors for x
def get_primes(x):
non_primes = set()
primes = set()
for i in range(2, x+1):
if x%i == 0 and i not in non_primes:
primes.add(i)
j = i
while j*i <= x:
non_primes.add(i*j)
j += 1
return primes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment