How would I solve this part of the Fibonacci sequence piecewise function?

f(n) = f(n-1)+f(n-2) if n > 1. Thanks

n = 4

What do you mean solve it ?

f(0) = 1
f(1) = 1
f(2) = 2
f(3) = 1+2 = 3
f(4) = 2+3 = 5
f(5) = 3+5 = 8
f(6) = 5+8 = 13
f(7) = 8+13 = 21

and on and on

Google Fibonacci Sequence

I'm being asked to solve f(4) = f(4-1) + f(4-2). The answers is 3, but I don't know how to get to that answer. Thanks

f(4) = f(3)+f(2) = 3 + 2 = 5

as I showed you above.

The answer is not 3 but 5

To solve the part of the Fibonacci sequence piecewise function f(n) = f(n-1) + f(n-2) for n > 1, you would need to apply the recursive definition of the Fibonacci sequence.

Here's a step-by-step explanation:

1. Define the base cases: The Fibonacci sequence starts with two initial values, typically taken as f(0) = 0 and f(1) = 1. These values act as the base cases for the recursive function.

2. Determine the values of f(n-1) and f(n-2): To calculate f(n), you need to know the values of f(n-1) and f(n-2), which are the two previous terms in the sequence. If n is greater than 1, you can use the piecewise function f(n) = f(n-1) + f(n-2) to find the value of f(n) recursively.

3. Use iteration or recursion: To calculate f(n) iteratively, start from the base cases and incrementally calculate each term until you reach f(n). Alternatively, you can use recursion to call the function f recursively until you reach one of the base cases.

4. Calculate f(n): By repeatedly applying the recursive definition, you will eventually find f(n), where n is the desired term of the Fibonacci sequence.

Overall, the Fibonacci sequence can be solved using either iteration or recursion, depending on your preference or requirements.