This may not be exactly what you want, but it should do the trick.
sub next_prime_iterator { my $num = shift; do { $num++ } until is_prime($num); return $num; } sub is_prime { my $guess = shift; return 1 if $guess == 2; return unless $guess > 2 and $guess % 2; my $max = 1 + int $guess ** .5; for ( my $divisor = 3; $divisor < $max; $divisor += 2 ) { return unless $guess % $divisor; } return 1; }
Cheers,
Ovid
New address of my CGI Course.
In reply to Re: Finding the next larger prime.
by Ovid
in thread Finding the next larger prime.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |