태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

function getNumbersList(elements, count) { var a; var numbersList = []; --count; for (a = 0; a < elements.length; a++) { if (count == 0) { numbersList.push(elements[a]); } else { var dupplicatedElements = elements.slice(); var first = dupplicatedElements.splice(a, 1); var recursiveList = getNumbersList(dupplicatedElements, count); for (b = 0; b < recursiveList.length; b++) { numbersList.push(first.toString() + recursiveList[b].toString()); } } } return numbersList; } var elements = [1, 2, 3, 4, 5, 6, 7, 8, 9]; var numbersList = getNumbersList(elements, 9); var answerList = []; for (i = 0; i < numbersList.length; i++) { var numbers = numbersList[i]; abc = parseInt(numbers.substring(0, 3)); de = parseInt(numbers.substring(3, 5)); fghi = parseInt(numbers.substring(5, 9)); if (abc * de == fghi) { answerList.push(numbers); } } for (i = 0; i < answerList.length; i++) { document.querySelector("#test_result").innerHTML += answerList[i] + "
"; }

댓글을 달아 주세요