개념
<script>
/*
[약수의 누적]
- 반복문을 사용하여 18의 약수를 모두 출력하고,
출력한 약수들을 누적 합산하여 최종 합계를 출력하시오.
*/
/*
[출력예시]
1 2 3 6 9 18
39
*/
let total = 0;
for(let i = 1; i <= 18; i++) {
if(18 % i == 0) {
document.write(i, " ");
total += i;
}
}
document.write("<br>");
document.write(total);
</script>
HTML
복사


