sub isPrime($) { $num = shift; my ($i,$c); for ($i = 1; $i < $num / 2; $i++) { if ($num % $i == 0){$c += 1;} } if ($c == 1){return 1;} return 0; }