Apr-03-2019, 02:04 AM
(Apr-03-2019, 01:30 AM)ichabod801 Wrote: I would have usedIchabod, you mean that my code doesn't work, right? I'll find and correct the bug. Thanks for revealing it.not number % divisor
, and not bothered with the divides function.
Also, your code does work right. It returns False for 6. Going to the sqrt(n) is fine for checking for primes, but if you need all of the divisors it's going to miss lots.
You make a good point about the divides function. Maybe I'm to OCD about boolean expressions because I'm a purist. So years ago, when my Sun workstation complained that I put a non-boolean expression in a C program's while-loop condition, I replaced it with a boolean one.
Another purist pet peeve of mine is a break statement that stops a loop before the loop condition comes true or gets falsified. That's why I'd much rather force that condition to be true or force it to be false.