영상
개념
<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
복사