MathGroup Archive 2012

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

Search the Archive

Re: Percentage of Primes

Minimalist approach:

 Count[Range[#], _?PrimeQ]/# & /@

With bells and whistles:

 Module[{data, pt},
  data = Count[Range[#], _?PrimeQ]/# & /@
  pt = {nmax, data[[-1]]};
   Frame -> True,
   Axes -> False,
   PlotRange -> {-0.02, 0.7},
   MaxPlotPoints -> 150,
   PlotStyle -> Darker[Red],
   Epilog -> {Blue, AbsolutePointSize[2],
      NumberForm[N[data[[-1]]], {4, 3}],
      pt, {1, 2}]}]],
 {nmax, 25, 1000, 25,
  Appearance -> "Labeled"}]

Bob Hanlon

On Sat, Sep 22, 2012 at 2:47 AM, Jared E <eggers.jared at> 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-ax is 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.  Thanks, Jared

  • Prev by Date: Low-level notebook programming for custom document generation
  • Next by Date: Re: Percentage of Primes
  • Previous by thread: Percentage of Primes
  • Next by thread: Re: Percentage of Primes