All non-prime factorings
- by Tony Veijalainen
Let's say we have numbers factors, for example 1260:
>>> factors(1260)
[2, 2, 3, 3, 5, 7]
Which would be best way to do in Python combinations with every subproduct possible from these numbers, ie all factorings, not only prime factoring, with sum of factors less than max_sum?
If I do combinations from the prime factors, I have to refactor remaining part of the product as I do not know the remaining part not in combination.
Example results would be:
[4, 3, 3, 5, 7] (one replacement)
[3, 6, 14, 5] (two replacements)