title: How Do I Print the values in a recursive Program in Java?
body: <p>I am trying to use a recursive program to print out a sequence that starts at one value, goes to a max, then back down to the original value.  The program can't use static or global variables, or use an array.  </p>
  
  <p><strong>Ex: <code>f(5,10)</code> prints <code>5,6,7,8,9,10,9,8,7,6,5</code></strong></p>
  
  <p>I think I have the concept down, at least I think I do, but I can't figure out how to print the variable from the recursive method to print the sequence.<br>
  Here is my program:</p>
  
  <pre><code> public class recursive {
  
       public static int f(int a, int b) {
           System.out.print(a);   
           if (a == b) return a;
           else return a + f(a + 1, b) + a;
  
       public static void main(String[] args) {
           f(2, 5);
       }
  
   }
  </code></pre>
  
  <p>Do I need to Change the program to be able to print? I am fairly certain my concept is correct, I just can't print it.  Please help!!!!</p>