title: Combinations with replacement Java
body: <p>For the last couple of days, I am trying to solve this problem of combinations with replacement in java. I checked other languages as well maybe it was done in them and I could translate to java but with no luck, so any help greatly appreciated.</p>
  
  <p>So here is the problem(mock interview question) I came upon:</p>
  
  <p>Combine from range 0 - 6(n)
  In an array of size r (let's say 3)</p>
  
  <p>So the formula for combinations with replacement is C(n,r)=(n+r−1)! / r!(n−1)!. In this case the combinations will be 84</p>
  
  <pre><code>000
  010,
  011,
  ...,
  025,
  055,
  ...,
  666.
  </code></pre>
  
  <p>However, I can't get my head around this algorithm WITH REPLACEMENT which is an entirely different story from without replacement.</p>
  
  <p>Thank you again in advance for your help.</p>