Welcome to the Monastery PerlMonks

### Re: a close prime number

by chromatic (Archbishop)
 on Feb 11, 2005 at 20:48 UTC ( #430266=note: print w/replies, xml ) Need Help??

in reply to a close prime number

That's really easy:

```sub find_closest_primes
{
my \$number = shift;

my @close_primes;

for my \$close (find_close_numbers( \$number ))
{
push @close_primes, \$close if is_prime( \$close );
}

return @close_primes;
}

All you have to do is fill in the behavior of find_close_numbers() and is_prime()!

Replies are listed 'Best First'.
Re^2: a close prime number
by belden (Friar) on Feb 11, 2005 at 21:12 UTC
Re^2: a close prime number
by water (Deacon) on Feb 13, 2005 at 19:33 UTC
Your solution reminds me of me of a article currently referenced from the Joel on Software homepage, which talks about the the do-magic-here step.

:)

I don't necessarily think of it as magic; I didn't know what the supplicant would consider a "close" number nor did I know which prime number finding algorithm he might find acceptable.

It's not really a joke answer. It's how I would divide the problem if I were doing it.

Create A New User
Node Status?
node history
Node Type: note [id://430266]
help
Chatterbox?
 [shmem]: holli: all of our machinery is more perfect in its realm than any human being in theirs (Günther Anders), which doesn't mean not having fun, albeit dangerous sometimes. [ww]: That's a big "if", holli.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (14)
As of 2017-11-21 13:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
In order to be able to say "I know Perl", you must have:

Results (301 votes). Check out past polls.

Notices?