Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Prime Plotting in Mathematica - help needed

  1. Apr 14, 2010 #1
    Hey guys!

    Basically I have a table of prime numbers. What is to write this table as an image - from 1 too 480000 - showing each cell that is a prime as white and the others as black.

    So basically I'm cycling the numbers from 1-480000 and if they are prime then I want the cell white and otherwise black. I also want to be able to wrap the table to 800x600 pixels.

    Any help appreciated since I have no idea how to do this!
  2. jcsd
  3. Apr 22, 2010 #2


    Staff: Mentor

    With[{w = 800, h = 600},
    Table[Boole[PrimeQ[w i + j + 1]], {i, 0, h - 1}, {j, 0, w - 1}]]]]
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook