Search

반복문6_개념05_공배수

대분류
STEP04 일차반복문
문제 난이도
수학
소분류
일차반복문6_개념

영상

개념

<script> /* [문제] 12와 15의 공배수를 작은 것부터 순서대로 5개만 출력하시오. [정답] 60 120 180 240 300 */ let x = 12; let y = 15; let count = 0; let i = y; let run = true; while(run) { if(i % x == 0 && i % y == 0) { console.log(i); document.write(i + "&nbsp;"); count += 1; if(count == 5) { run = false; } } i += 1; } </script>
Java
복사