(프로그래머스) 124 나라의 숫자

유지원·2022년 6월 4일
0

프로그래머스

목록 보기
58/66

문제 링크

https://programmers.co.kr/learn/courses/30/lessons/12899?language=javascript


Javascript

function solution(n) {
	let answer = "";
	const array1_2_4 = new Array(4, 1, 2);

	while(n) {
		answer = array1_2_4[n % 3] + answer;
		n = Math.floor((n - 1) / 3);
	}

	return answer;
}
profile
👋 https://github.com/ujw0712

0개의 댓글