in reply to YAPNC: Yet another prime number checker?
Secondly, you could speed things up a little more: you only need to check all integer numbers up to ceil( $input / 2 ) because of the commutative properties of integers (2*3 == 3*2).
Furthermore, prime are always (except for '2', so almost always) odd numbers, so you could skip them in your test for even more speed improvement!
-- JaWi
"A chicken is an egg's way of producing more eggs."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: YAPNC: Yet another prime number checker?
by nefertari (Chaplain) on Oct 09, 2002 at 07:32 UTC | |
by JaWi (Hermit) on Oct 09, 2002 at 07:39 UTC | |
|
Re: Re: YAPNC: Yet another prime number checker?
by martymart (Deacon) on Nov 22, 2002 at 15:02 UTC |