1. Hello,

I'm practicing java for fun, and I came across this problem I can't solve. Can anyone who knows java help me out on this? I'm practicing as much as I can for the AP computer science exam in may. ok here goes:

The fibonacci sequence is a famous bit of mathematics, and it happens to have a recursive definition. The first two values in the sequence are 0 and 1 (essentially 2 base cases). Each subsequent value is the sum of the previous two values, so the whole sequence is: 0, 1, 1, 2, 3, 5, 8, 13, 21 and so on. Define a recursive fibonacci(n) method that returns the nth fibonacci number, with n=0 representing the start of the sequence.
fibonacci(0) → 0
fibonacci(1) → 1
fibonacci(2) → 1

The problem is from JavaBat, a really cool site for people like me who are starting Java. I know what the Fibonacci sequence is, but I have no clue on how to translate it into code and follow the recursive requirement.

I know the answer is somewhere online, but I need someone to explain the process in understandable terms.  Posting Permissions
 You may not post new threads You may not post replies You may not post attachments You may not edit your posts   BB code is On Smilies are On [IMG] code is On [VIDEO] code is On HTML code is Off Trackbacks are On Pingbacks are On Refbacks are On Forum Rules