There is a program here about fiboannaci, that each time the code branches off again you are calling the fibonacci function from within itself two times.
if number < 2
fibonacci(number - 1) + fibonacci(number - 2)
This is just the direct 1:1 translation (with a simple twist) of the standard mathematical definition of the Fibonacci Function:
Fib(0) = 0 Fib(1) = 1 Fib(n) = Fib(n-2) + Fib(n-1)
Translated to Ruby, this becomes:
def fib(n) return 0 if n.zero? return 1 if n == 1 fib(n-2) + fib(n-1) end
It's easy to see that the first two cases can be combined: if n is 0, the result is 0, if n is 1, the result is 1. That's the same as saying if n is 0 or 1, the result is the same as n. And "n is 0 or 1" is the same as "n is less than 2":
def fib(n) return n if n < 2 fib(n-2) + fib(n-1) end
There's nothing special about this, it's the exact translation of the recursive definition of the mathematical Fibonacci function.