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);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNegativeValuesIterative() { fibonacciNumbers.getIterative(-1); }
@Test public void firstNumberInFibonacciSequenceIsThreeIterative() { assertEquals(1, fibonacciNumbers.getIterative(1)); }
@Test public void fourthNumberInFibonacciSequenceIsThreeIterative() { assertEquals(5, fibonacciNumbers.getIterative(4)); }
@Test public void eleventhNumberInFibonacciSequenceIsIterative() { assertEquals(144, fibonacciNumbers.getIterative(11)); }