sm 기술 블로그
67. 10870(피보나치수열) 본문
let input = require("fs").readFileSync(0).toString().split(" ");
const fibonacci = (n) => {
if (n === 0) return 0;
if (n === 1) return 1;
return fibonacci(n - 2) + fibonacci(n - 1);
};
console.log(fibonacci(parseInt(input[0])));
설명:
https://smhope.tistory.com/184
70. 10872 (팩토리얼)
N = int(input()) def factorial(N): if(N == 1 or N == 0): return 1 else: return N*factorial(N-1) print(factorial(N)) 재귀 함수 이용 https://smhope.tistory.com/183 함수를 호출하고 다시 자" data-og-hos..
smhope.tistory.com
'문제 > 백준_자바스크립트' 카테고리의 다른 글
69. 2447 (별 찍기 -10) (0) | 2022.06.08 |
---|---|
68. 17478 (재귀함수가 뭔가요?) (0) | 2022.06.06 |
66. 10872 (팩토리얼) (0) | 2022.06.06 |
65. 9020(골드바흐의 추측) (0) | 2022.06.05 |
64. 4948(베르트랑 공준) (0) | 2022.06.04 |
Comments