Created
February 5, 2014 11:26
-
-
Save 668/8821629 to your computer and use it in GitHub Desktop.
# Prime factorization - list 因数分解
This file contains hidden or 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
# Prime factorization - list 因数分解 | |
def primes(n): | |
primfac = [] | |
d = 2 | |
while d*d <= n: | |
while (n % d) == 0: | |
primfac.append(d) # supposing you want multiple factors repeated | |
n /= d | |
d += 1 | |
if n > 1: | |
primfac.append(n) | |
return primfac | |
l = primes(195132894**2) | |
print l | |
# [2, 2, 3, 3, 11, 11, 37, 37, 79907, 79907] | |
# 求正公约和 | |
print (1+2+2**2)*(1+3+3**2)*(1+11+11**2)*(1+37+37**2)*(1+79907+79907**2) | |
n = 195132894**2 | |
# divisors = [ d for d in xrange(2,n//2+1) if n % d == 0 ] | |
# print divisors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment