@Test public void firstNumberInFibonacciSequenceIsThreeIterative() { assertEquals(1, fibonacciNumbers.getIterative(1)); }
public int getIterative(int n) { validateInput(n); if (n <= 1) { return 1; } int previous = 1; int current = 1; int element = 0; for (int i = 2; i <= n; i++) { element = previous + current; previous = current; current = element; } return element; }
FibonacciNumbers { public int getIterative(int n) { validateInput(n); if (n <= 1) { return 1; } int previous = 1; int current = 1; int element = 0; for (int i = 2; i <= n; i++) { element = previous + current; previous = current; current = element; } return element; } }
FibonacciNumbers { public int getIterative(int n) { validateInput(n); if (n <= 1) { return 1; } int previous = 1; int current = 1; int element = 0; for (int i = 2; i <= n; i++) { element = previous + current; previous = current; current = element; } return element; }  }
FibonacciNumbers { public int getIterative(int n) { validateInput(n); if (n <= 1) { return 1; } int previous = 1; int current = 1; int element = 0; for (int i = 2; i <= n; i++) { element = previous + current; previous = current; current = element; } return element; }  int getRecursive(int n); int getIterative(int n); int getRecursiveWithCatching(int n); }
FibonacciNumbers { public int getIterative(int n) { validateInput(n); if (n <= 1) { return 1; } int previous = 1; int current = 1; int element = 0; for (int i = 2; i <= n; i++) { element = previous + current; previous = current; current = element; } return element; }  int getRecursive(int n); int getIterative(int n); int getRecursiveWithCatching(int n);  }