MathGroup Archive 2003

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

Search the Archive

Re: Processing lists of unrelated numbers with Do or While statement

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39185] Re: [mg39175] Processing lists of unrelated numbers with Do or While statement
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Mon, 3 Feb 2003 01:08:25 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I don't quite understand what you mean by "processing unrelated  
numbers", but ...
first of all , you can just map your test function onto range of  
integers, e.g.

And @@ (PrimePi[2#] - PrimePi[#] ¡Ã 1 & /@ Prime/@Range[2,100])

True


Of course if you want to know the actual difference you can use:

In[17]:=
PrimePi[2#]-PrimePi[#]&/@Prime/@Range[2,100]


Out[17]=
{1,1,2,3,3,4,4,5,6,7,9,9,9,9,11,13,12,13,14,13,15,15,16,19,20,19,19,18,1 
8,23,\
23,25,25,27,26,28,28,28,28,30,30,32,32,32,32,35,38,38,38,39,39,39,41,42, 
43,42,\
42,42,42,42,44,49,50,49,49,54,54,56,55,55,55,57,58,59,59,60,60,60,61,64, 
64,66,\
66,66,67,67,68,68,67,67,70,71,71,73,72,73,77,76,80}

and of course lots of different variants of this.

Andrzej Kozlowski
Yokohama, Japan
http://www.mimuw.edu.pl/~akoz/
http://platon.c.u-tokyo.ac.jp/andrzej/



On Sunday, February 2, 2003, at 03:13 PM, Diana wrote:

> Folks,
>
> 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.
>
> Well,
>
> 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.
> Is there a way to process unrelated numbers with a Do or While or  
> NestWhile
> statement?
> Thanks,
> Diana
>
> --
> =====================================================
> "God made the integers, all else is the work of man."
> L. Kronecker, Jahresber. DMV 2, S. 19.
>
>
>
>



  • Prev by Date: Re: Re: Writing a program to hunt for a prime between n^2 and (n+1)^2
  • Next by Date: RE: Re: Writing a program to hunt for a prime between n^2 and (n+1)^2
  • Previous by thread: Re: Processing lists of unrelated numbers with Do or While statement
  • Next by thread: To verify Cauchy-Riemann relations in complex variable graphically