in reply to
Prime Number Finder

Here's the code I've used for this in the past. I believe it's fairly efficent. If you're going to use it like in the root node in this thread, it's best to check only odd numbers, as suggested by ichimunki.

`#!usr/bin/perl -w
use strict;
sub prime {
my $number = shift;
my $d = 2;
my $sqrt = sqrt $number;
while(1) {
if ($number%$d == 0) {
return 0;
}
if ($d < $sqrt) {
$d++;
} else {
return 1;
}
}
}
my $number = $ARGV[0];
print prime($number);
`

**elusion** **:** **http://matt.diephouse.com
**

**
**