영상
개념
<script>
/*
[문제]
5~15 사이의 숫자 중에서
[조건1] 4의 배수를 출력하고,
[조건2] 그 총합을 구하시오.
[조건3] 그 개수를 출력하시오.
[정답]
8 12
합 = 20
개수 = 2
*/
let total = 0;
let count = 0;
let i = 5;
while(i <= 15) {
if(i % 4 == 0) {
console.log(i);
document.write(i + " ");
total += i;
count += 1;
}
i += 1;
}
console.log("합 = " + total);
console.log("개수 = " + count);
document.write("<br>")
document.write("합 = " + total + "<br>");
document.write("개수 = " + count);
</script>
Java
복사