영상
문제
<script>
/*
[문제]
50에서 100까지 자연수 중에서
9의 배수의 개수를 출력하시오.
[정답]
6개
*/
</script>
Java
복사
해설
<script>
/*
[문제]
50에서 100까지 자연수 중에서
9의 배수의 개수를 출력하시오.
[정답]
6개
*/
let count = 0;
let i = 50;
while(i <= 100) {
if(i % 9 == 0) {
console.log(i);
document.write(i + "<br>");
count += 1;
}
i += 1;
}
console.log(count);
document.write(count);
</script>
Java
복사