title: Iterate through every permutation of an array of numbers
body: <p>My problem is such: I have n amount of numbers in an array, each with a maximum value m, and I would like to iterate through every permutation of these numbers, by incrementing them individually until they reach their maximum. </p>
  
  <p>An example: </p>
  
  <pre><code>[0,0,0,0]
  
  Integer @ index 0 has a max value of 5
  Integer @ index 1 has a max value of 3
  Integer @ index 2 has a max value of 4
  Integer @ index 3 has a max value of 6
  
  Output: 
  [0,0,0,1]
  [0,0,0,2]
  [0,0,0,3]
  .
  .
  .
  [0,1,1,0]
  [0,1,1,1]
  [0,1,1,2]
  [0,1,1,3]
  .
  .
  .
  [5,0,2,1]
  [5,0,2,2]
  etc.
  </code></pre>
  
  <p>Python has itertools with the product function, which would solve my problem, but it does not look like Java has something similar. Recursion seem to be the way to go but I can figure out the way forward. </p>
  
  <p>Does anyone know how to achieve above mentioned output?
  Thanks in advance :-)</p>