Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve (a, b) {
- let arr2 = [1];
- let iterator = 0;
- for (let i = 0; i < a - 1; i++) {
- if (arr2.length <= b) {
- iterator = 0;
- } else {
- iterator = arr2.length - b;
- }
- arr2.push(arr2.slice(iterator, b + iterator).reduce((acc, curr) => acc + curr));
- }
- console.log(arr2.join(' '));
- }
Advertisement
Add Comment
Please, Sign In to add comment