in reply to Re: YAPNC: Yet another prime number checker?

in thread YAPNC: Yet another prime number checker?

You can stop at `sqrt($input)`.

Example:

The divisors of 100 are:

1, 2, 4, 5, 10, 20, 25, 50, 100. They come in pairs as follows:

and so on. So at 10 which is1*100 = 100 2*50 = 100 4* 25= 100 5*20 = 100 10*10 =100 20*5= 100

`sqrt(10)`you are at the point where the second factor is smaller than the first and you have already tested for this pair.

Replies are listed 'Best First'. | |
---|---|

Re^3: YAPNC: Yet another prime number checker?
by JaWi (Hermit) on Oct 09, 2002 at 07:39 UTC |

In Section
Seekers of Perl Wisdom

Comment onRe: Re: YAPNC: Yet another prime number checker?SelectorDownloadCode