MathGroup Archive 2003

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

Search the Archive

Re: Writing a program to hunt for a prime between n^2 and (n+1)^2


On 2/2/03 at 1:13 AM, diana53xiii at earthlink.remove13.net (Diana) wrote:

>My program, which is not fancy:

>NRange = Flatten[{n, Range[10, 20, 1]}]
>NSquared = Flatten[NRange^2]
>NPlus1Squared = Flatten[(NRange+1)^2]

>FirstPrimeGreaterNSquared=Flatten[{"Prime>n^2",Table[NestWhile[#1+1&,n
>^2,!(P rimeQ[#1])&],{n,10,20}]}]

>{NRange, NSquared, FirstPrimeGreaterNSquared, NPlus1Squared} //
>TableForm

>Are there ideas to make this more snazzy, and accomplish the same
>thing?


<<NumberTheory`Master`
TableForm[
    {#,#^2,NextPrime[#^2],(#+1)^2}&/@Range[10,20],
    TableHeadings->{None,{n,n^2,"Prime>n^2",(n+1)^2}}]


  • Prev by Date: Re: Random Trouble
  • Next by Date: Re: Random Trouble
  • Previous by thread: Re: Re: Writing a program to hunt for a prime between n^2 and (n+1)^2
  • Next by thread: RE: Writing a program to hunt for a prime between n^2 and (n+1)^2