Okay, I don't know how many of you are big into math, but I'm making a program to calculate power sets with up to 5 elements. I basically have an array of 5 text boxes (index 0 to 4). The user can type in the number of elements they have, and then type an element in each text box.

If you don't know what a power set is, it basically finds every possible combo of elements within the set and outputs them to a list (including the full set, as well as the empty set).

For example, the power set of {1,2,3} is {1},{2},{3},{1,2},{2,3},{1,3},{},{1,2,3}

I achieved this output by using nested for loops.

I start with a simple for loop

Code:
for i = 0 to maxEl.text
list1.additem ("{" & text1(i).text & "}")
next
this grabs all combos of only 1 element. I then move on to 2 combined elements

Code:
for i = 0 to maxEl.text
for j = i+1 to maxEl.txt
list1.additem ("{" & text1(i).text & "," & text1(j).text & "}")
next
next
I keep adding nested for loops for more numbers.

Finally, I add the entire set, as well as the empty set "{}" to the end of the list.

This all works fine and dandy. My next task, the one I'm having trouble with, is exponential power sets. For example, the power set of a power set of a power set. Do any of you have an idea of how I would tackle this? Everything is saved in a listbox, so it's essentially in an array. If anyone has any ideas, please let me know.

Thanks