in reply to YAPNC: Yet another prime number checker?

I have a couple of questions regarding what you are doing. On the following line:

next if ( $last_digit == 5 or $last_digit = 0 );

did you mean:

next if ( $last_digit == 5 or $last_digit == 0 );

also to make it run even faster you might want to look to have it only check from $input to sqrt($input). If it does not fail up to the
sqrt($input) it will not fail past that point.

-Enlil

Replies are listed 'Best First'.
Re: Re: YAPNC: Yet another prime number checker?
by snafu (Chaplain) on Oct 08, 2002 at 23:02 UTC
    Whoa! Good catch :) I will fix that. You are right, that is what I intended to do.

    Another thing that has been suggested to me is an xor to ignore certain values passed or some kind of bit-shifting for the same purpose. I need to look into that more since that kind of arithematic manipulation is really new to me.

    _ _ _ _ _ _ _ _ _ _
    - Jim
    Insert clever comment here...