title: Permutation of sequence?
body: <p>I have a specific amount of numbers. Now I want to somehow display all possible permutations of this sequence.</p>
  
  <p>For example if the amount of numbers is 3, I want to display:</p>
  
  <pre><code>0 0 0
  0 0 1
  0 0 2
  0 1 0
  0 1 1
  0 1 2
  0 2 0
  0 2 1
  0 2 2
  1 0 0
  1 0 1
  1 0 2
  1 1 0
  1 1 1
  1 1 2
  1 2 0
  1 2 1
  1 2 2
  2 0 0
  2 0 1
  2 0 2
  2 1 0
  2 1 1
  2 2 0
  2 2 1
  2 2 2
  </code></pre>
  
  <p>I have this code to do that where depth is the amount of numbers. Obviously this code isn't working correct. Any hints how to improve?:</p>
  
  <pre><code>    for (int i = 0; i &lt; (depth * depth); i++) {
  
          path = setPath(depth, path, i);
  
          print(path);
      }
  
      private static int[] setPath(int depth, int[] path, int i) {
  
      for (int j = 1; j &lt;= depth; j++) {
  
          if (j == 1) {
              path[depth-1] = i%depth;
          } else {
              path[depth-j] = i / ((j-1)*depth);  
          }
      }
  
      return path;
  }
  </code></pre>