Skip to content

Instantly share code, notes, and snippets.

@mmourafiq
Created August 27, 2012 19:00
Show Gist options
  • Save mmourafiq/3491358 to your computer and use it in GitHub Desktop.
Save mmourafiq/3491358 to your computer and use it in GitHub Desktop.
multiplicities of prime factors less than x
def get_primes_multiplicities(x):
"""
Returns factors for x!
"""
p_multi = {}#factors multiplicities
for p in primes_less(x):
temp = x
mult = 0
while temp!= 0:
temp /= p
mult += temp
p_multi[p] = mult
return p_multi
def nbr_factors(x):
nbr = 0
for f in get_primes_multiplicities(x).values():
nbr += (f + 1)
return nbr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment