예제
<script>
/*
[문제]
5! 을 구하시오.
*/
/*
[출력예시]
120
*/
</script>
HTML
복사
정답
<script>
/*
[문제]
5! 을 구하시오.
*/
/*
[출력예시]
5
120
*/
let a = 5;
document.write(a, "<br>");
// [for문]
let total = 1;
for(let i = 1; i <= a; i++) {
total *= i;
}
document.write(total);
document.write("<br>");
// [while문]
let total2 = 1;
let i = 1;
while(i <= a) {
total2 *= i;
i += 1;
}
document.write(total2);
</script>
HTML
복사


