2013-04-17 14:34:39 +08:00

50 lines
655 B
Python

def mkp(n):
P = [2]
p = [2]
x = 3
while len(P) < n:
for i in p:
if x % i == 0:
break
else:
P.append(x)
while x > p[-1]**2:
p.append(P[len(p)])
x += 2
return P
primes = mkp(1000)
def factor(x):
out = []
for p in primes:
if p * p > x:
break
if x % p == 0:
count = 0
while x % p == 0:
x /= p
count += 1
out.append(count)
if x > 1:
out.append(1)
return out
def sum(x):
pre = factor(x)
out = 1
for i in pre:
out *= i * 2 + 1
return (out + 1) / 2
def maxx(x):
n = 4
while sum(n) < x:
n += 1
return n
print maxx(100000)