Question: Write a function, just the function in C++ using recursion to calculate the nth Tribonacci number where n is a nonnegative integer . Use Prototype:

Write a function, just the function in C++ using recursion to calculate the nth Tribonacci number where n is a nonnegative integer .

Use Prototype: int tribonacci(int n);

The first three Tribonacci numbers are tribonacci(0) = 0, tribonacci(1) = 0, and and tribonacci(2) = 1.

Subsequent terms are calculated by adding the previous three. For example, the fourth tribonacci number would be 0+0+1 = 1.

The first eight Tribonacci numbers are 0, 0, 1, 1, 2, 4, 7, 13

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!