There is an array for example [1,2,3], you need to get 1,11,12,13,111,112,113,122,123,133,2,22,23,222,223,233,3,33,333
You can simplify to get combinations of only a certain length, while doing this:
public class Test { private static void PFunction(int index[], int max){ for (int i=0; i<index.length; i++) index[i] = 0; int curIndex = index.length-1; while(true){ for (int anIndex : index) System.out.print(anIndex + " "); System.out.println(); for (int i=curIndex; i>=0; i--){ index[i]++; if (index[i] <= max) break; if (i==0) return; index[i] = 0; } } } public static void main(String[] args) { int index[] = new int[3]; PFunction(index, 3); } } But you need to get not all combinations, but only with unique values, that is, 0.0.3 and 3.0.0 and 0.3.0 - the same