http://qs321.pair.com?node_id=434517

Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:

All,
I am trying to improve my solution to this problem by incorporating the shortcuts I outlined here. This requires ordering the powerset of prime factors in some sort of progressive order:
input = 2, 3, 5, 7 output: 2 2 3 2 3 5 2 3 5 7 ------- 2 3 7 ------- 2 5 2 5 7 ------- 2 7 ------- 3 3 5 3 5 7 ------- 3 7 ------- 5 5 7 ------- 7 -------

In this simple example, the number is 210 so any factor larger than 14 need not be considered. This means that after checking 2*3*5, we can skip 2*3*5*7 and after we check 3*5, we can skip 3*5*7.

Additional savings can be found if the primes repeat since it will lead to duplicate subsets. Prior to determining the product of the subset, we can easily determine if we have already seen this subset and skip. If this previously seen subset was also too large, we can skip the entire progression.

Anyone have any ideas about how to implement this?

Cheers - L~R

Update: You can see the result of this exercise here