# Plot Ramanujan Primes

I often investigate on Ramanujan primes. Is it possible to apply this procedure described in DotPlot for prime numbers ? I think so but which is the condition I should use? I am trying from several days with no results. According to wolfram references, the basic code from them is the following:

   l = Table[PrimePi[x] - PrimePi[x/2], {x, 10^4}]; // Timing

1 + Last[Position[l, #]][[1]] & /@ Range[0, 50]


These two simple lines provide the first 50 Ramanujan primes. In particular, the primes are drawn in black in a binary image as shown below.

Is it possible to do the same with the Ramanujan primes? I mean, drawing black only the Ramanujan primes!

It is not clear how you want these Ramanujan primes displayed. The following uses NumberLinePlot (introduced in v10.0)

l = Table[PrimePi[x] - PrimePi[x/2], {x, 10^4}];

rp = 1 + Last[Position[l, #]][[1]] & /@ Range[0, 50];

NumberLinePlot[Tooltip /@ rp, ImageSize -> Large]


EDIT: Using ArrayPlot with Manipulate

Manipulate[
ArrayPlot[
Array[Boole[MemberQ[rp, #1] && MemberQ[rp, #2]] &, {rp[[n]],
rp[[n]]}],
FrameTicks -> Range[0, rp[[n]], Max[2, Round[rp[[n]]/10, 5]]]],
{{n, 6}, 1, 25, 1, Appearance -> "Labeled"}]


EDIT 2:

Manipulate[
ArrayPlot[Reverse@Array[
Boole[MemberQ[rp, #1] && MemberQ[rp, #2]] &, {rp[[n]], rp[[n]]}],
FrameTicks -> {Table[{rp[[n]] - m + 1, m}, {m, rp[[1 ;; n]]}],
rp[[1 ;; n]]}],
{{n, 6}, 3, 12, 1, Appearance -> "Labeled"}]


• Thanks for your reply. Your plot is interesting. As you can see here mathematica.stackexchange.com/questions/188073/…, the primes are drawn in black in a binary image. Is it possible to do the same with the Ramanujan primes? – Spook82 Dec 30 '18 at 16:48
• @Spook82 - I have guessed at what you may want; however, in the future specify exactly what you expect on each axis of a plot. Otherwise your questions may be closed as requiring additional information. – Bob Hanlon Dec 30 '18 at 20:12
• Dear Bob, thanks a lot and my sincerest apologies for my lack of details. In addition, I would like to know how I can invert the order of the axis-colomn. I mean that it should go from 0 to 45 and not from 45 to 0 as in the uploaded figure. I tried with the commands "rotate" and "reverse" but I did not work. The problem is that "Manipulate is not a graphic command" and I am not able to modify the "FrameTicks" in the code. I hope I was enough clear. – Spook82 Dec 31 '18 at 4:18