Can someone post code for generating all combinations of k elements out of n elements with repetitions. Example: elements = 1,2,3,4 and k=3 111, 112, 113, 114, 222, 221, 223, 224, 333, 331, 332, 334, 444, 441, 442, 443, 123, 124, 134, 234 Thanks. Tomaz