Search

반복문2_개념04_배수빼기

대분류
STEP03 조건문/일차반복문
문제 난이도
LV03
소분류
일차반복문2_개념

영상

개념

<script> /* [문제] 다음 조건이 전부 맞는 수를 출력하시오. [조건1] 13 이상 100미만의 숫자중에서 13의 배수를 전부 검사한다. [조건2] 그 중 6번째 배수에서 4번째 배수를 뺀 수를 구한다. [정답] 26 */ let count = 0; let x = 0; let y = 0; let i = 13; while(i < 100) { if(i % 13 == 0) { // document.write(i + "<br>"); count = count + 1; if(count == 4) { x = i; } if(count == 6) { y = i; } } i = i + 1; } document.write("y = " + y + "<br>"); document.write("x = " + x + "<br>"); let result = y - x; document.write("result = " + result); </script>
Java
복사