MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Prime Puzzle with Mathematica


amzoti wrote:

> trying to find an efficient way to this in Mathematica.
> 
> I found the answer - but it was a manual list manipulation - and it
> was ugly!
> 
> Any suggestions?
> 
> 3 Nice Primes:
> 
> Find three 2-digit prime numbers such that:
> 
>     * The average of any two of the three is a prime number, and
>     * The average of all three is also a prime number


Select[Subsets[Table[Prime[n], {n, 5, 25}], {3}],
  PrimeQ[1/3
      Plus @@ #] && (And @@ (PrimeQ[1/2 Plus @@@ Subsets[#, {2}]])) &]

The above expression returns the unique solution to the problem 
(assuming I have correctly understood it, of course :-)

Regards,
-- Jean-Marc



  • Prev by Date: Re: Prime Puzzle with Mathematica
  • Next by Date: FindFit
  • Previous by thread: Re: Prime Puzzle with Mathematica
  • Next by thread: Re: Prime Puzzle with Mathematica