-
-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
The task: here
The solution i am submitting works localy for me in VSC. I've tried to console.log, to see the input only, but still this error occurs:
Anyway the code for the solution is:
function lastKNumbersSequence(nTimes, kLastEl){
let result = [1];
for(let i = 1; i < nTimes; i++){
let startIndex = Math.max(0, i-kLastEl);
let curElement = result.slice(startIndex, startIndex + kLastEl).reduce((acc, el) => acc + el, 0);
result.push(curElement);
}
console.log(result);
}
Metadata
Metadata
Assignees
Labels
No labels