求助大佬,这个代码的意思,看不是很懂(有关python因数分解)
from random import randintdef factors(num, fac=[]):
for i in range(2, int(num**0.5)+1):
if num%i == 0:
fac.append(i)
factors(num//i, fac)
break
else:
fac.append(num)
facs = []
n = randint(2, 10**8)
factors(n, facs)
result = '*'.join(map(str, facs))
if n==eval(result):
print(n, '= '+result)
页:
[1]