Definition at line 5 of file main.cpp.
◆ tribonacci()
| int Solution::tribonacci |
( |
int |
n | ) |
|
|
inline |
Definition at line 8 of file main.cpp.
9 {
10 if (n == 0)
11 return 0;
12 else if (n == 1 || n == 2)
13 return 1;
14
15 int prev_prev = 0;
16 int prev = 1;
17 int current = 1;
18 for (int i = 3; i <= n; ++i)
19 {
20 int sum = prev_prev + prev + current;
21 prev_prev = prev;
22 prev = current;
23 current = sum;
24 }
25 return current;
26 }
Referenced by main().
The documentation for this class was generated from the following file: