영상
개념
<script>
/*
[문제]
75의 약수 중에서 작은 수부터 큰 수를 출력했을 때,
다섯 번째 약수만 출력하시오.
[정답]
25
*/
let num = 75;
let count = 0;
let i = 1;
while(i <= num) {
if(num % i == 0) {
count += 1;
if(count == 5) {
console.log(i);
document.write(i);
}
}
i += 1;
}
</script>
Java
복사