const fs = require('fs');
const path = process.platform === 'linux' ? '/dev/stdin' : './data.txt';
const input = Number(fs.readFileSync(path).toString().trim());
const solve = (input) => {
if (input <= 1) {
return input;
} else {
return solve(input - 1) + solve(input - 2);
}
};
console.log(solve(input));
์ฌ๊ทํจ์๋ฅผ ์ด์ฉํ๋ ๋ํ ๋ฌธ์ , ํผ๋ณด๋์น์์ด :)
'๐ JavaScript > ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JS] 2231 (0) | 2022.06.07 |
---|---|
[JS] 2798 (0) | 2022.06.07 |
[JS] 10872 (0) | 2022.05.28 |
[JS] 9020 (0) | 2022.05.23 |
[JS] 4948 (0) | 2022.05.23 |