我正在制作一个计算器来查找数字的因子,并且发现了这篇文章: What is the most efficient way of finding all the factors of a number in Python?
我会在哪里发表声明将所有因素附加到列表中?
def factors(n):
return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))