Code:

iteratively, it is simple but that's not acceptable as a solution.

How do you do it iteratively? If you have some sort of data structure that you're storing information in in a stack-like manner, you may be able to turn the stack into the function call-stack.

A hint for a recursive solution: you're basically calculating permutations with repetitions. Recursion is all about breaking problems down into smaller ones. Let's say your numbers are 0 and 1, and you want permutations of length 2. What possibilities are there? There's 0N and 1N, where 'N' is all of the permutations of length 2-1. What are the permutations of length 1? 0N and 1N, where 'N' is all of the permutations of length 1-1. What are the permutations of length 0? Just the empty string.