My thinking more along those lines:
- if num == 1 or if num % 2 == 0 -> it's not prime
- if num == 2 it's prime
- for other cases use loop to divide num with values in range(3, num, 2) to find whether there is divisor
It's still brute force, but 'half brute-force'.
EDIT:
The order is wrong. First should be num == 2 check.
- if num == 1 or if num % 2 == 0 -> it's not prime
- if num == 2 it's prime
- for other cases use loop to divide num with values in range(3, num, 2) to find whether there is divisor
It's still brute force, but 'half brute-force'.
EDIT:
The order is wrong. First should be num == 2 check.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.