PyExperiments/FoundFactors/foundFactors.py
Andrea Bontempi d38c765b70 Init
2021-10-21 15:08:06 +02:00

13 lines
296 B
Python

def foundDivisors(x):
for i in range(1,abs(x)+1):
if x % i == 0:
yield i
def foundFactors(x, n, found=[]):
if n <= 1:
return [found+[x]]
ret = []
for d in foundDivisors(x):
ret += foundFactors(int(x/d), n-1, found+[d])
return ret