int IterativeRabbit(int N) // Iterative solution to the rabbit problem. { // initialize base cases: int Previous = 1; // initially Rabbit(1) int Current = 1; // initially Rabbit(2) int Next = 1; // result when N is 1 or 2 // compute next Rabbit values when N >= 3 for (int I = 3; I <= N; ++I) { // Current is Rabbit(I-1), Previous is Rabbit(I-2) Next = Current + Previous; // Rabbit(I) Previous = Current; // get ready for Current = Next; // next iteration } // end for return Next; } // end IterativeRabbit