From 6f718972538ed36e086d9d360357c79a52d06c46 Mon Sep 17 00:00:00 2001 From: beurmuz Date: Tue, 17 May 2022 10:26:34 +0900 Subject: [PATCH] =?UTF-8?q?#8=2022.05.17=20>=202=EB=B2=88=20=EC=9D=B4?= =?UTF-8?q?=EC=A7=84=EC=88=98=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/inf/recursive,dfs/2.js | 18 ++++++++++++++++++ src/inf/recursive,dfs/README.md | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/inf/recursive,dfs/2.js diff --git a/src/inf/recursive,dfs/2.js b/src/inf/recursive,dfs/2.js new file mode 100644 index 00000000..29bcdc4a --- /dev/null +++ b/src/inf/recursive,dfs/2.js @@ -0,0 +1,18 @@ +'use strict'; + +function solution(n) { + let answer = ''; + function recursive(n) { + if(n === 0) { + return; + } else { + // console.log()시 순차 출력 + recursive(parseInt(n/2)); + answer += String(n%2); // 여기서 출력하면 거꾸로 나옴 + } + } + recursive(n); + return answer; +} + +console.log(solution(11)); \ No newline at end of file diff --git a/src/inf/recursive,dfs/README.md b/src/inf/recursive,dfs/README.md index 06fca008..07ceae6f 100644 --- a/src/inf/recursive,dfs/README.md +++ b/src/inf/recursive,dfs/README.md @@ -5,7 +5,7 @@ |번호|정답여부|재응시| |:---:|:---:|:---:| |1|△|한번 더 풀기| -|2||| +|2|O|한번 더 풀기| |3||| |4||| |5|||