# Displaying primes as a 3D array of spheres

I am currently learning my way through Mathematica and have stumbled upon a strange problem. It is asking me to implement PrimeQ into Graphics3D (specifically for spheres). I typed it up and displayed a picture in the notebook uploaded at the link below. If someone could explain this to me, I would greatly appreciate it and will move on to the next chapter, Pure Functions.

Disregard the input I entered. I was just trying a generic example to see how both compare in front of each other.

http://ge.tt/4Xi1kvZ1/v/0?c

P.S. I'm only 14 years old. I'm working through a Mathematica book, so that I may use Mathematica to enter into the Intel or Semmes Science Fairs next year.

• Prime /@ Range@PrimePi[1000] gives you the prime numbers ... now you should solve how to "number" the 3D cells from 1 to 1000 ... – Dr. belisarius Apr 16 '14 at 1:37
• Thank you for your speedy response. The prime numbers from 1 to 1000 is rather easy, although I would've used Select from Table OR Case from Table. The problem I am having is exactly the one you mentioned. Numbering the cells. Once I figure how to assign each coordinate to a specific number, I ought to be able to use Graphics3D and define Spheres at those coordinates. Also, I think the radius of the spheres is 1/2. Can somebody please confirm that? – mildused Apr 16 '14 at 1:41
• Try Graphics3D[Table[If[PrimeQ[100 i + 10 j + k + 1], Sphere[{i, j, k}, 1/2]], {i, 0, 9}, {j, 0, 9}, {k, 0, 9}]] – Dr. belisarius Apr 16 '14 at 1:58
• Why did you range the i,j,k to only nine? Why should it not range to 10? Otherwise, it looks the same. Thanks so much. – mildused Apr 16 '14 at 2:08
• Try Flatten@Table[100 i + 10 j + k + 1, {i, 0, 9}, {j, 0, 9}, {k, 0, 9}] and Flatten@Table[100 i + 10 j + k + 1, {i, 1, 10}, {j, 1, 10}, {k, 1, 10}] – Dr. belisarius Apr 16 '14 at 2:12

IntegerDigits[Prime /@ Range@PrimePi[1000], 10, 3] // ListPointPlot3D