I'm trying to find all of the prime factors for a given number. The following code achieves this:
However, if I remove the boolean
test isPrime, as below, I get additional numbers after the highest prime factor.
I can't work out why this should be. From my understanding, the divisor only gets added to the list of primes if the loop doesn't break (which, with the boolean test would be true anyway). What am I not understanding?