Sequence sum
Question: After
learning about divisors, Xiao Ming is very curious about divisors. He found that given a positive integer t, we can always find an integer containing t divisors. Xiao Ming is very interested in the smallest number containing t divisors and defines it as St.
For example, S1=1, S2=2, S3=4, S4=6,...
Now Xiao Ming wants to know, when t = 100, what is St?
Idea:
We can first count the prime numbers within 100,000, and then use the knowledge of number theory to find the divisor of a number. We calculate the decomposed prime factor of a number and then add 1 to the exponent of the prime factor and add it to the other The exponent of the prime factor is multiplied by 1 to get the solution of this divisor.
For example:
the prime factor of the decomposition of 6 is 2 3, and the exponent of 2 is (1+1) (1+1) the exponent of 3, so the divisor of 6 is 4,
and then we can find the nearest 100 divisor in the for traversal. Up. Answer: 45360
program:
def z(a): #判断质数
if a==2 or a==3:
return 1
if a%2==0 or a==1:
return 0
k=1
while k*k<=a:
k+=2
if a%k==0:
return 0
return 1
b=[]
for p in range(2,100000):
if z(p):
b.append(p)
def yu(a): #a的约数有多少
s=[]
i=0
k=1
while a!=1:
if a%b[i]==0:
a=a//b[i]
s.append(str(b[i]))
if z(a):
s.append(str(a))
break
else:
i+=1
s1=set(s)
for i in s1:
k*=s.count(i)+1
return k
c=0
while 1:
c+=1
if 100==yu(c):
print(c)
break
Reprinting is prohibited. Only for self-study. No responsibility for program errors.