Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: YAPNC: Yet another prime number checker?

by Enlil (Parson)
on Oct 08, 2002 at 22:26 UTC ( [id://203782]=note: print w/replies, xml ) Need Help??


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...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://203782]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-25 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found