Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lastKNumbersSequence(n, k) {
- let arr = new Array(k + n - 1).fill(0);
- arr[k - 1] = 1;
- for (let i = k; i < n + k - 1; i++){
- for (let j = i - k; j < i; j++){
- arr[i] += arr[j];
- }
- }
- arr.splice(0, k - 1);
- console.log(arr.join(' '));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement