Re: Processing lists of unrelated numbers with Do or While statement
- To: mathgroup at smc.vnet.net
- Subject: [mg39202] Re: Processing lists of unrelated numbers with Do or While statement
- From: Bill Rowe <listuser at earthlink.net>
- Date: Mon, 3 Feb 2003 01:10:28 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 2/2/03 at 1:13 AM, diana53xiii at earthlink.remove13.net (Diana) wrote: >I had a problem recently where I tried to determing the PrimePi value >of 2 times a number minus that number. This is verifying the >Bertrand's Postulate: >PrimePi(2x) - PrimePi(x) >=1 for all x >=2, elements of Z. >I finally came up with: PrimePi[2*{2, 3, 5, 7, 13, 23, 43, 83, 163, >317, 631, 1259, 2503, 4001} - {2, 3, 5, 7, 13, 23, 43, 83, 163, 317, >631, 1259, 2503, 4001}] >gives: {1, 2, 3, 4, 6, 9, 14, 23, 38, 66, 115, 205, 368, 551} the >desired answer. Hmm... Your statement of your problem and the function agree but are not equivalent to PrimePi[2x]-PrimePi[x]. Your function is PrimePi[2*list -list] = PrimePi[list] which is not equal to PrimePi[2*list]-PrimePi[list] >Is there a way to process unrelated numbers with a Do >or While or NestWhile statement? Clearly, the answer to your question is yes. A more specific answer depends on exactly what you mean by "process". If process feed numbers to a function of n arguements m times then a better solution might be MapThread[f, {list1, list2, .... listn}]