in reply to Re^9: Number functions.. primes (ugly code runs faster)
in thread Number functions I have lying around
A number cannot be prime if it is a perfect square. 16 is perfect square of 4. 16 not prime.
A number is only prime if two other integers cannot be multiplied together to equal that number.
Take 37, sqrt = 6.08
Our next number would be 7. But we know that 6.08 times any number smaller than 6.08 is < 37 and 6.08 times any number larger than 6.08 is > 37
So, in our next iteration, 7 * something = 37 with no remainder, for that something to multiply 7 and make 37, would *have* to be smaller than 6.08, and we already tested all those.
Does that sound right?
|
|---|