MathGroup Archive 2012

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

Search the Archive

Re: Percentage of Primes

  • To: mathgroup at
  • Subject: [mg128195] Re: Percentage of Primes
  • From: Bill Rowe <readnews at>
  • Date: Sun, 23 Sep 2012 02:59:53 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:

On 9/22/12 at 2:47 AM, eggers.jared at (Jared E) wrote:

>I'm brand new to Mathematica, so there's only so much I can teach
>myself by playing around with it.  Could somebody give me some
>sample code for displaying a graph of the percentage of primes from,
>say, 1 to 1000.  The x-axis would be the integers from 1 to 1000 and
>the y-axis would indicate the density of primes from 1 to n.  I can
>then figure out how to apply this code to other types of problems.

Code for doing what you describe is pretty simple if you take
use of built-in functions Mathematica offers. For example,

DiscretePlot[PrimePi[n]/n, {n, 2, 1000}, PlotRange -> All]

or perhaps a log scale provides a better display

ListLogPlot[Table[{n, PrimePi[n]/n}, {n, 2, 1000}], PlotRange -> All]

  • Prev by Date: Re: Front end - Error when saving file
  • Next by Date: Re: Percentage of Primes
  • Previous by thread: Re: Percentage of Primes
  • Next by thread: Re: Percentage of Primes