Home Segments Top Top Previous Next

453: Mainline

The following diagram shows the rabbits method works, given the task of determining the number of Fibonacci rabbits at the end of 3 months:

Arguments     | ^      Returned values 
            3 | |  3   
              v | 
           *-------------* 
           | First call  | 
           *-------------* 
              | ^    |  ^ 
            2 | |  1 |  *------------* 
              | |    *-------------* |  
              v | 2                v | 1 
           *-------------*   *-------------* 
           | Second call |   | Fifth call  | 
           *-------------*   *-------------* 
              | ^    |  ^ 
            1 | |  0 |  *------------* 
              | |    *-------------* | 
              v | 1                v | 1 
           *-------------*   *-------------* 
           | Third call  |   | Fourth call | 
           *-------------*   *-------------*