Question: I've been playing with some code tonight and I coded a very simple algorithm that I think is a very good solution for a fibonacci recursive and for big numbers. I would like to know what you guys think about it and if you have any contribution for making it better, share with us... take a look at the code bellow

```
public class RecursiveFibonacci {

    public void calculateFib(long first, long next, long counter, int n) {
        if(counter == n) {
            return;
        }
        counter++;
        if(first == 0 && next == 0) {
            System.out.println("0");
            calculateFib(0, 1, counter, n);
            return;
        }

        if(first == 0 && next == 1) {
            System.out.println("1");
            calculateFib(1, 0, counter, n);
            return;
        }

        if(first == 1 && next == 0) {
            System.out.println("1");
            calculateFib(1, 1, counter, n);
            return;
        }

        long result = first + next;
        if(result > 1) {
            System.out.println(result);
                calculateFib(next, result, counter, n);
        }
    }

    public RecursiveFibonacci() {
        calculateFib(0, 0, 0, 9999999);
    }

    public static void main(String[] args) {
        new RecursiveFibonacci(); 
    }

}

```

Answer: 
The best way to compute the i-th Fibonacci is not by recursion. You can use these formulas:

![enter image description here](https://i.stack.imgur.com/Iv4GR.png)

![enter image description here](https://i.stack.imgur.com/hT1XA.png)

![enter image description here](https://i.stack.imgur.com/Fe34D.png)

phi is the golden ratio. However the problem with Fibonacci numbers is not related to the method to use but to the number of digits of number. They will become difficult to write for large numbers.
Because F 9999999 has ~2089876 digits, you'll want to use an [approximation](http://en.wikipedia.org/wiki/Fibonacci_number). Also consider [memoization](https://stackoverflow.com/q/1799990/230513).