Re: read/write at the same time
- From: Dr J R Stockton <jrs@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 4 Nov 2008 13:30:01 +0000
In alt.comp.lang.borland-delphi message <a49d4381-795e-47d0-8dcb-
177373f5da67@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, Mon, 3 Nov 2008 14:51:39,
"alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx> posted:
On 3 Nov, 13:39, dolatabadi.a...@xxxxxxxxx wrote:
<snip>
We divide it to all prime numbers below it<snip>
and if it is not divisable, this number is prime.
Don't you only need to divide by primes from 3 to the prime below one-
(primeth you've just tested) of the number ?
eg at the start you divide by 3 and if it is not divisible, then you
set the limit to test up to at one-third the number. After not
divisible by five, you set the limit at one-fifth the number. In the
end you'd never test for division above the geatest prime less than
the square-root of the number.
There is never any need to test with a number greater than the square
root of the input. If there is a prime factor greater than the square
root, there must be a corresponding factor smaller than the square root.
Also, see in <http://www.merlyn.demon.co.uk/js-misc1.htm>.
--
(c) John Stockton, near London. *@merlyn.demon.co.uk/?.?.Stockton@xxxxxxxxxxx
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Correct <= 4-line sig. separator as above, a line precisely "-- " (SoRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)
.
- References:
- read/write at the same time
- From: dolatabadi . amir
- Re: read/write at the same time
- From: Maarten Wiltink
- Re: read/write at the same time
- From: dolatabadi . amir
- Re: read/write at the same time
- From: alanglloyd@xxxxxxx
- read/write at the same time
- Prev by Date: Re: Inherited component using thread and synchronize
- Next by Date: Re: Delphi V7 PRNG?
- Previous by thread: Re: read/write at the same time
- Next by thread: Re: read/write at the same time
- Index(es):
Relevant Pages
|