Skip to content

Instantly share code, notes, and snippets.

@ssanin82
Created February 7, 2015 07:02
Show Gist options
  • Save ssanin82/0f3eb0536ca15beb7738 to your computer and use it in GitHub Desktop.
Save ssanin82/0f3eb0536ca15beb7738 to your computer and use it in GitHub Desktop.
def get_prime_factors(n):
dd = defaultdict(lambda: 0)
if n > 1:
i = 2
while i * i <= n:
if n % i == 0:
dd[i] += 1
n /= i
i = 2
else:
i += 1
dd[n] += 1
return dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment