mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-13 06:23:00 +08:00
Fixing the spaces identation
This commit is contained in:
parent
2d87b6f7b3
commit
8ee786a598
@ -5,18 +5,18 @@
|
|||||||
* @return {number[]}
|
* @return {number[]}
|
||||||
*/
|
*/
|
||||||
export default function tribonacci(n) {
|
export default function tribonacci(n) {
|
||||||
const tribSequence = [0];
|
const tribSequence = [0];
|
||||||
let currentValue = 1;
|
let currentValue = 1;
|
||||||
|
|
||||||
if(n >= 2) {
|
if(n >= 2) {
|
||||||
tribSequence.push(currentValue);
|
tribSequence.push(currentValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 2; i < n; i++) {
|
for (let i = 2; i < n; i++) {
|
||||||
tribSequence.push(currentValue);
|
tribSequence.push(currentValue);
|
||||||
currentValue += tribSequence[i - 1] + tribSequence[i - 2];
|
currentValue += tribSequence[i - 1] + tribSequence[i - 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
return tribSequence;
|
return tribSequence;
|
||||||
}
|
}
|
||||||
|
|
@ -5,14 +5,14 @@
|
|||||||
* @return {number}
|
* @return {number}
|
||||||
*/
|
*/
|
||||||
export default function tribonacciNth(n) {
|
export default function tribonacciNth(n) {
|
||||||
const tribSequence = [0, 0, 1];
|
const tribSequence = [0, 0, 1];
|
||||||
let currentValue = 1;
|
let currentValue = 1;
|
||||||
|
|
||||||
for (let i = 3; i <= n; i++) {
|
for (let i = 3; i <= n; i++) {
|
||||||
tribSequence.push(currentValue);
|
tribSequence.push(currentValue);
|
||||||
currentValue += tribSequence[i - 1] + tribSequence[i - 2];
|
currentValue += tribSequence[i - 1] + tribSequence[i - 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
return tribSequence[n];
|
return tribSequence[n];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user