Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Input: '1', '0', '5', '5' (line = 5)
- // Expect output:
- // 1
- // 0 5
- // 6 11 22
- // 39 72 133 244
- // 449 826 1519 2794 5139
- // Output:
- // 1
- // 0 5
- // 6 11 22
- // 39 72 133 244
- // 39 72 133 244 449 826 1519 2794 5139
- let firstNum = +gets();
- let secondNum = +gets();
- let thirdNum = +gets();
- let line = +gets();
- let array = [];
- print(firstNum);
- print(secondNum, thirdNum);
- if (line > 2) {
- for (let i = 3; i <= line; i++) {
- for (let j = 0; j < i; j++) {
- let tempNum = firstNum + secondNum + thirdNum;
- firstNum = secondNum;
- secondNum = thirdNum;
- thirdNum = tempNum;
- array.push(thirdNum);
- }
- if (array.length === 3) {
- print(array.toString().replace(/,/g, ' '));
- } else {
- print(array.slice(3).toString().replace(/,/g, ' '));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement