N-th Tribonacci Number
N-th Tribonacci Number asks you to return the term at a given non-negative position in a sequence starting with 0, 1, and 1, where each value is the sum of the three preceding values.
We'll cover the following...
We'll cover the following...
Statement
Given a number n, calculate the corresponding Tribonacci number.
The Tribonacci sequence is defined as:
| , and for |
|---|
The input number, n, is a non-negative integer.
Constraints:
-
n - The answer is guaranteed to fit within a 32-bit integer, i.e., answer
Examples
Understand the problem
Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
N-th Tribonacci Number
1.
What is the 5th Tribonacci number?
A.
5
B.
7
C.
15
D.
4
1 / 3
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Try it yourself
Implement your solution in the following coding playground:
Python
usercode > main.py
def find_tribonacci(n):# Replace this placeholder return statement with your codereturn -1
Click "Run" to evaluate your code.
Nth Tribonacci Number