Created
August 27, 2012 18:58
-
-
Save mmourafiq/3491343 to your computer and use it in GitHub Desktop.
finding prime factors for x
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 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