Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lastKseq(lengthOfSeq, previousElementCount) {
- let arr = [1];
- for (let i = 1; i < lengthOfSeq; i++) {
- let nextElement = 0;
- for (let j = 1; j <= previousElementCount; j++) {
- if (i - j >= 0) {
- nextElement += (arr[i - j]);
- }
- }
- arr.push(nextElement);
- }
- console.log(arr.join(" "));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement