Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: YAPNC: Yet another prime number checker?

by Enlil (Parson)
on Oct 08, 2002 at 22:26 UTC ( #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? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2022-06-27 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (86 votes). Check out past polls.

    Notices?