Question: In either Java or C# Instead of a regular Fibonacci number, you are supposed to calculate a special one as follows: F(n) = F(n-1)+ 2

In either Java or C#

Instead of a regular Fibonacci number, you are supposed to calculate a special one as follows:

F(n) = F(n-1)+ 2 * F(n-2) + 3 * F(n-3)

As an example, if F(0) = F(1) = F(2) = 1, then we have:

F(3) = F(2) + 2 * F(1) + 3 * F(0) = 1 + 2 + 3 = 6 F(4) = F(3) + 2 * F(2) + 3 * F(1) = 6 + 2 + 3 = 11

Given F(0), F(1), F(2), and N, your job is to calculate F(N).

Input Format

First number is F(0), second number is F(1), third number is F(2), and last number is N.

Example input: 1 1 1 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!