Perl: the Markov chain saw | |
PerlMonks |
YAPNC: Yet another prime number checker?by snafu (Chaplain) |
on Oct 08, 2002 at 21:48 UTC ( [id://203769]=perlquestion: print w/replies, xml ) | Need Help?? |
snafu has asked for the wisdom of the Perl Monks concerning the following question:
I hope this is a good place to put this. I was on www.ca-osi.com doing some geek challenges and started perusing the site for some ideas how to solve one of the puzzles when I happened upon a prime number generator. I wondered about how the developer was doing his generator and the fact that it only went from 1 to 100. I decided to have my own go at it. Well, here it is. If you folks could take a gander at it and tell me what you think I'd appreciate it. If you guys like it I will place it in snippets. I don't want to place something there that is buggy or cludgy which is why I figured placing it here first would be a good idea.
Oh, now this isn't a generator. This is a number checker. So just run it with a number to check. I am not doing any bounds checking so if you use a huge number this script will be limited by what your machine arch can handle. I am also not checking for negative numbers so Im not sure how it will work if you use one. Any and all feedback would be very appreciated.
I made some small changes to the other guy's code (since his was a generator and mine was a checker...I made his a checker and left his algorythm alone) and tried checking how quick his worked compared to mine and mine was significantly faster than his. This is a learning project for me so I am not looking at getting ripped to shreds unless it will be beneficial to me. :)
TIA guys.
_
_
_
_
_
_
_
_
_
_
Back to
Seekers of Perl Wisdom
|
|