영상
문제
<script>
/*
[문제]
[1] 5~15 사이의 숫자 중에서
[2] 7보다 큰 수 중 4의 배수인 수를 출력하고 그 개수를 출력한다.
[정답]
8
12
2개
*/
</script>
Java
복사
해설
<script>
/*
[문제]
[1] 5~15 사이의 숫자 중에서
[2] 7보다 큰 수 중 4의 배수인 수를 출력하고 그 개수를 출력한다.
[정답]
8
12
2개
*/
let num = 5;
let count = 0;
let i = 1;
while(i <= 15) {
if(7 < num && num % 4 == 0) {
console.log(num);
document.write(num + "<br>");
count = count + 1;
}
num = num + 1;
i = i + 1;
}
console.log(count + "개");
document.write(count + "개");
</script>
Java
복사