Recursive Algorithm For Array Permutations With Repetition