자바스크립트
home
2025 자바스크립트 초급 1500제
home

E0704_개념01_약수의개수

개념

<script> /* [약수의 개수] - 반복문을 사용하여 5의 약수를 모두 구해 출력하고, 출력한 약수들의 개수도 함께 출력하시오. */ /* [출력예시] 1 5 2 */ let count = 0; for(let i = 1; i <= 5; i++) { if(5 % i == 0) { document.write(i, " "); count += 1; } } document.write("<br>"); document.write(count); </script>
HTML
복사

영상