O'Reilly logo

Test-Driven Java Development - Second Edition by Viktor Farcic, Alex Garcia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the Fibonacci service

Most of you might be familiar with Fibonacci's numbers. Here's a brief explanation anyway for those who don't know what they are.

Fibonacci's sequence is an integer sequence resulting from the recurrence f(n) = f(n-1) - f(n - 2). The sequence starts with being f(0) = 0 and f(1) = 1. All other numbers are generated applying the recurrence as many times as needed until a value substitution can be performed using either 0 or 1 known values. That is: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,... More info about Fibonacci's sequence can be found here: http://www.wolframalpha.com/input/?i=fibonacci+sequence

As an extra functionality, we want to limit how long the value computation takes, so we impose a constraint ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required