Re: How to find the next prime number?



For a proven prime it is dynamic enough. Take i as even and divide i + 1
by all odd numbers less than the square root of i + 1. If any division has
a zero remainder then i + 1 is not prime. And if i + 1 is not prime then
move to i + 3 and begin again.

Actually i + 1 only needs to be divided by primes less than its square
root but the overhead of producing those primes is too much unless a range
of primes greater than i is needed.

But if a range of primes greater than i is needed such as all primes from
i + 1 in steps of 2 to i + 499 then divide i + 1 by 3, take the integer
part of that result, add 2 to it, multiply by the 3, check to see if that
result is greater than i + 499, if not add another 2 and multiply by the
3 again, and continue until greater than i + 499 with each mulitplication
result between i and i + 499 clearing out a possible odd in an existing
array. Next move to the 5, begin again, and continue the overall process
up to the square root of i + 499...


http://www.kbhscape.com/prime.htm

Actually, I put the odd composites into an empty array (without sorting)
and then work with the un-assigned elements of the array as the primes...


Actually, I put the odd composites into correct position of an empty array
(without the workload of a traditional sort) and then work with the
un-assigned elements of the array as the primes...


.



Relevant Pages

  • Re: How to find the next prime number?
    ... Actually i + 1 only needs to be divided by primes less than its square root ... between i and i + 499 clearing out a possible odd in an existing array. ...
    (sci.math)
  • Re: About alternatives to Matlab
    ... No it doesn't create a new array. ... Matlab, ... What you seem to be missing is that slice assignment shares data. ... takes a slice of x's data (in this case, the odd elements of x: ...
    (comp.lang.python)
  • Re: Formulating sentences in a possibly consistent ZF
    ... You might be interested to know that Goldbach's weak conjecture, ... every integer greater than 5 can be written as the sum of 3 primes, ... single odd ... on Dedekind's property of infinity. ...
    (sci.logic)
  • Re: My talk about Godel to the post-grads.
    ... the union is what is in A or B or both. ... The set of primes is really the property of being prime. ... Those numbers that have the property of being odd can be referred to ... My original objection was that without a prior bringing together of A and B we could not announce AuB when only A plays an actual role in it. ...
    (sci.logic)
  • Re: Formulating sentences in a possibly consistent ZF
    ... You might be interested to know that Goldbach's weak conjecture, ... every integer greater than 5 can be written as the sum of 3 primes, ... we can't define odd numbers in the same manner! ... on Dedekind's property of infinity. ...
    (sci.logic)