MathGroup Archive 2003

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

Search the Archive

Re: Re: goldbach prime partitions for arbitrary integer n => 4

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43030] Re: [mg43007] Re: goldbach prime partitions for arbitrary integer n => 4
  • From: Dr Bob <drbob at bigfoot.com>
  • Date: Sat, 9 Aug 2003 02:57:32 -0400 (EDT)
  • Organization: Space Corps
  • References: <bgsn4c$nnq$1@smc.vnet.net> <200308080426.AAA05562@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

Here are a couple of solutions using Sow and Reap:

primePartition[n_Integer] := First@Last@
      Module[{p, k},
        Reap[
          For[k = 1, k â?¤ PrimePi[n/2], k++,
            p = Prime@k;
            If[PrimeQ[n - p], Sow@{p, n - p}]]
          ]
        ]
primePartition@200

or

ClearAll@primePartition
testAndSow[n_] := Module[{p = Prime@#}, If[PrimeQ[n - p], Sow@{p, n - p}]] 
&
primePartition[n_Integer] := First@Last@Reap[testAndSow[n] /@ 
Range@PrimePi[n/2]]
primePartition@200

But this is my favorite solution, I think:

ClearAll@primePartition
primePartition[n_Integer?Positive] :=
   Transpose@{n - #, #} &@
     Select[n - Prime@Range@PrimePi[n/2],PrimeQ]
primePartition@200

Bobby

On Fri, 8 Aug 2003 00:26:22 -0400 (EDT), Bob Hanlon <bobhanlon at aol.com> 
wrote:

> primePartition[n_Integer] :=
> Select[
> Table[
> {Prime[p], n-Prime[p]}, {p, PrimePi[n/2]}], PrimeQ[#[[2]]]&];
>
> primePartition[200]
>
> {{3, 197}, {7, 193}, {19, 181}, {37, 163}, {43, 157}, {61, 139}, {73, 
> 127}, {97, 103}}
>
>
> Bob Hanlon
>
> In article <bgsn4c$nnq$1 at smc.vnet.net>, 
> gilmar.rodriguez at nwfwmd.state.fl.us
> (=?ISO-8859-1?Q?Gilmar_Rodr=EDguez_Pierluissi?=) wrote:
>
> << If one wishes to compute:
> eqn={p+q==200}; constraints={2<=p<=100, p<=q, p,q \[Element]Primes};
> wouldn't it be nice that if you evaluate:
> Solve[eqn,constraints,{p,q}]
> you would get:
> {{97,103},{73,127},{61,139},{43,157},{37,163},{19,181},{7,193},{3,197}} ?
> A module (or program) that could solve:
> eqn={p+q==n}; constraints={2<=p<=n/2, p<=q, p,q \[Element]Primes};
> Solve[eqn,constraints,{p,q}]
> for a specified n, (n=>4, n \[Element]Integer), would be even better!
> >><BR><BR>
>
>



-- 
majort at cox-internet.com
Bobby R. Treat


  • Prev by Date: Re: RuleCondition vs Condition
  • Next by Date: Re: Re: goldbach prime partitions for arbitrary integer n => 4
  • Previous by thread: Re: goldbach prime partitions for arbitrary integer n => 4
  • Next by thread: Re: goldbach prime partitions for arbitrary integer n => 4