Nth Tribonacci Number
Given a number n, calculate the corresponding Tribonacci number.
Statement
Given a number , calculate the corresponding Tribonacci number. The Tribonacci sequence is defined as:
, and for |
---|
Constraints
The input number, , is a non-negative integer.
Example
Sample input
4
Expected output
4
Try it yourself
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.