Re: Percentage of Primes

*To*: mathgroup at smc.vnet.net*Subject*: [mg128192] Re: Percentage of Primes*From*: Bob Hanlon <hanlonr357 at gmail.com>*Date*: Sun, 23 Sep 2012 02:58:52 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*Delivered-to*: l-mathgroup@wolfram.com*Delivered-to*: mathgroup-newout@smc.vnet.net*Delivered-to*: mathgroup-newsend@smc.vnet.net*References*: <20120922064747.0DFD4685F@smc.vnet.net>

Minimalist approach: ListPlot[ Count[Range[#], _?PrimeQ]/# & /@ Range[1000]] With bells and whistles: Manipulate[ Module[{data, pt}, data = Count[Range[#], _?PrimeQ]/# & /@ Range[nmax]; pt = {nmax, data[[-1]]}; ListPlot[ data, Frame -> True, Axes -> False, PlotRange -> {-0.02, 0.7}, MaxPlotPoints -> 150, PlotStyle -> Darker[Red], Epilog -> {Blue, AbsolutePointSize[2], Point[pt], Text[ 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 gmail.com> 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 >

**References**:**Percentage of Primes***From:*Jared E <eggers.jared@gmail.com>