mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Fixing the algorithm
This commit is contained in:
parent
9a9c92d353
commit
d02bd00ed3
@ -6,12 +6,14 @@
|
||||
*/
|
||||
export default function tribonacci(n) {
|
||||
const tribSequence = [0];
|
||||
let currentValue = 1;
|
||||
let currentValue = 0;
|
||||
|
||||
if (n >= 2) {
|
||||
tribSequence.push(currentValue);
|
||||
}
|
||||
|
||||
currentValue += 1;
|
||||
|
||||
for (let i = 2; i < n; i += 1) {
|
||||
tribSequence.push(currentValue);
|
||||
currentValue += tribSequence[i - 1] + tribSequence[i - 2];
|
||||
|
Loading…
Reference in New Issue
Block a user