문제
풀이 과정
3진법과 유사한 방법으로 풀이
const solutionA = (n) => {
let answer = '';
const numArr = [4, 1, 2];
while (n > 0) {
answer = numArr[n % 3] + answer;
if (n % 3 !== 0) n = Math.floor(n / 3);
else n = n / 3 - 1;
}
return answer;
};
const testA = solutionA(10);
console.log(testA);
틀린 부분이 있거나 보충해야 할 내용이 있다면 댓글이나 DM(sungstonemin)으로 알려주시면 감사하겠습니다😄