I'm working on a program which factors polynomials:

www.hampleman.com/quadeqfact.exe
I found a bug in the algorithm that factors numbers. If I input a number like 24 it breaks it down into a list of prime numbers: 2 * 2 * 2 * 3. Then it starts with the first in the list, mult by the remaining, adds it to the list of factors. The list of factors is a list of ordered pairs, each ordpair has 2 numbers which mult by each other, gets 24, in this case, then takes the first 2 in the list and mult by the rest. Then it takes the first 3 mult them together to get a list of (2,12) (4,6) (8,3) (1,24). This algorithm works fine for numbers like this, but for numbers like 2310 which breaks down to 2 * 3 * 5 * 7 * 11, I can't use this method because it doesn't try all possible combinations. I'm trying to think of an elegant solution that can try all possible combinations. Any suggestions?

Dan

In the case of 2310 = 2 * 3 * 5 * 7 * 11 use a 5 bit binary number and count from 00001 to 11110 like:

00001

00010

00011

00100

..

11100

11101

11110

In the case of 00011, the 0's represent 2 * 3 * 5 = 30 and the 1's represent 7 * 11 = 77.