Question: Lately, I started to test something that's been on my mind for a while now. The Fibonacci sequence scheme has several methods to get solved, but in this instance I'm trying to do something slightly different. I'm trying to use recursion with numbers given by the user at the CLI. This is what I got so far. I'm including an iterative version that seems to work for comparison purposes. 

Numbers given by user at CLI: 4 and 6. The number **9** is the **n** here. 

Iterative:

```
1: ite: 6 
2: ite: 10
3: ite: 16
4: ite: 26
5: ite: 42
6: ite: 68
7: ite: 110
8: ite: 178
9: ite: 288

```

Recursive:

```
1: rec: 16
2: rec: 33
3: rec: 59
4: rec: 102
5: rec: 171
6: rec: 283
7: rec: 464
8: rec: 757
9: rec: 1231

```

Method for recursive version:
here **num0** and **num1** are the variables that hold the values given at CLI. 

```
public int Recursive(int n) {
    //....
        int a = num0;
        int b = num1;
        if(n < 0)
        {
          return n;
        }else{
           int c = a+b;
           a = b;
           b = c;
          return Recursive(n-1)+Recursive(n-2)+c;     
        }
    }

```

Any thoughts or ideas are greatly appreciated.

Answer: 
To use two arbitrary numbers as the starting points, you just need to take the simple fibonacci recursive version and tweak the base case slightly. Instead of just returning `n` when `n` is `0` or `1`, we check for specific values of `n` and return the appropriate starting values. Remember, the base case(s) are just the answers to the problems that cannot be broken down anymore by recursion.

```
public int recurse(int first, int second, int n)
{
    switch (n)
    {
        case 0:  return first;
        case 1:  return second;
        default: return recurse(first, second, n - 1) + recurse(first, second, n - 2);
    }
}

```

To use the above function, you can do something like:

```
public static void main(String[] args)
{
    int first =  // get from user (first number in the sequence)
    int second = // get from user (second number in the sequence)
    int n =      // get from user (which number in the sequence to compute)
    int answer = recurse(first, second, n);

    System.out.println(answer);
}

```

Note that since first and second are passed in every function call and never change, they could be stored as instance fields or globals to avoid passing them every time the function is called.
You do not need temp variables with recursion. The arguments for each call (in this case n) is your changing value for each recursive call. So you just operate on it. If you are at the base case (n = 2, or n = 1, or n = 0) you just give it back. Otherwise you call fibonacci again on a smaller value. 

```
int fibonacci(int n) {
    if (n < 2) {
        return n;
    }

    return fibonacci(n-1) + fibonacci(n-2);
}

```