title: How to pass variables in recursion
body: <p>I want to do something like recursive dfs and my main function only gets one parameter - the state I need to get to. My helper function can get any set of parameters. What I need is to get to the end state and remember my moves. So I think I can call the functions recursively and reduce the state (represented by length I need to reach) each time but how do I save the way to get there? I wanted to use a string but I can't pass it along...</p>
  
  <p>The idea of the code is to get to a certain length when I can go in steps of 1 or 2</p>
  
  <p>Pseudo code:</p>
  
  <pre><code>helper(path, step_length, length_to_go):
      if(step_length == length)
          return path.concat(step_length);
      Main(length_to_go - step_length);
  
  Main(length):
      string path = "";
      int step1 = 1, step2 = 2;
      helper(path, step1, length);
      helper(path, step2, length);
  </code></pre>
  
  <p>The problem is in the call to main, the path string wouldn't carry on, wouldn't it?</p>