All non-prime factorings
Posted
by
Tony Veijalainen
on Stack Overflow
See other posts from Stack Overflow
or by Tony Veijalainen
Published on 2011-03-05T23:13:05Z
Indexed on
2011/03/05
23:24 UTC
Read the original article
Hit count: 204
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)
© Stack Overflow or respective owner