I need help understanding a programming assignment.

I need to use recursion to create all the possible combinations of n-digit numbers (n <= 5) that can be obtained from a list of single digit, non-repeating numbers (1-9).

For example if I have an array containing {1,2} and I wanted all the 3 digit combinations from that I would get: 111 112 121 122 211 212 221 222. Like wise if I wanted all of the 2 digit combinations from {1,2,3} it would be 11 12 13 21 22 23 31 32 33.

It seems to me that the number of combinations will be k^n, where k is the number of numbers and n is the number of digits but I'm not sure if this is an accurate observation.

I understand how to solve the problem with a fixed number of digits using loops but I can't seem to figure out how to deal with a variable number of digits other then I would need n-loops for n-digits.

I don't understand what the base or recursive case for this problem would be. Any hints or pointers would be much appreciated.

Thanks in advance.

- Z