sneakyimp;11036507 wrote:
That's definitely an impressive improvement.
See my last post above. Unfortunately that was simply due to moving an expression out of the for conditional. It is still an improvement, but they are not that far apart. One evaluates every third number (2 out of 6). The other evaluates every other number (odd numbers).
sneakyimp;11036507 wrote:
Are we certain of these assertions?
The first part is that there is at most one primefactor > sqrt(N). If sqrt(N) is R and R is an integer, then RR = N and there is no factor > R. If sqrt(N) is r and r is not an integer, let ceil(r) be R, the smallest integer > than r. Then R r is > N and therefor any other factor(s) of N has to be < r. Therefor, if you have found no divisor in the range 2 .. floor(sqrt(N)), there can be no divisor in ceil(sqrt(N)) .. N.
sneakyimp;11036507 wrote:
are you certain that ALL primes fit this form?
For the second part, all integers can be written as 6k + i, for some integer k and i = -1, 0, 1, 2, 3, 4
6k + 0
6k + 1
6k + 2
6k + 3
6k + 4
6k + 5 => 6 (k+1) -1
Every time you reach 6k + 5 (every 6th integer), you increase k by 1 and reset i to -1
Looking at these expressions, you will find that
1. is divisible by 2 and 3
3. is divisible by 2
4. is divisible by 3
5. is divisible by 2
This only leaves cases 2. and 6. that we are not certain about. Thus, any prime will be expressible as 6k ± 1. But not all numbers expressible as 6k ± 1 are prime though.