I have a javascript algorithm which prints out the prime factors of a number based on a user's input.
<script>
var number = parseInt( prompt("Enter the number";""))
var divisor = 2;
while( number >= divisor){
if (number % divisor == 0) {
document.write(divisor + "");
} else {
divisor++;
}
}
</script>
This code runs in (N-1) times at its worst, and I need to make it run ((N/2)/2) + 1 times. For example, if I test input number 53, it will take 14 loops instead of 52. How do I make it more efficient?