Skip to content

Instantly share code, notes, and snippets.

@rbricheno
Created September 17, 2019 14:49
Show Gist options
  • Save rbricheno/2272acbe240f624bf25a300f18f6d3df to your computer and use it in GitHub Desktop.
Save rbricheno/2272acbe240f624bf25a300f18f6d3df to your computer and use it in GitHub Desktop.
def factorize(x):
"""Takes an integer. Returns a list of its prime factors."""
fluffy = []
boring = set()
for i in range(2, x+1):
if i not in boring:
fluffy.append(i)
boring = boring.union({j for j in range(i*i, x+1, i)})
return [tardigrade
for tardigrade
in fluffy
if x % tardigrade == 0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment