title: Time complexity of this recursive function
body: <p>I have this recursive function. I want to know the time complexity of this algorithm. The idea is given a number, we have to find all the subsets that sum to the give number</p>
  
  <pre><code>public void getSequences(int n, ArrayList&lt;Integer&gt; buffer, int sum) {
    if(sum == n) {
       for(int j=0; j&lt;buffer.size(); j++) {
           System.out.print(buffer.get(j) + " ");
       }
       System.out.println("");
    }
  
    for(int i=1; i&lt;n; i++) {
       sum += i;
       if(sum &gt; n) {
         break;
       }
       buffer.add(i);
       getSequences(n, buffer, sum);
       sum -= i;
       buffer.remove(i);
    }
  }
  
  ArrayList&lt;Integer&gt; buffer = new ArrayList&lt;Integer&gt;();
  getSequences(3, buffer, 0);
  
  // Output
  // 1 1 1
  // 1 2 
  // 2 1
  </code></pre>
  
  <p>What is the time complexity of this algorithm?</p>