How to Create a Prime Number Image in Mathematica?

In summary, the conversation was about creating a table of prime numbers and displaying it as an image with white cells representing prime numbers and black cells representing non-prime numbers. The table was to have a size of 800x600 pixels and the code provided was a way to achieve this. The person asking for help was unsure of how to create this table and was seeking assistance.
  • #1
RyanJ
17
6
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!
 
Physics news on Phys.org
  • #2
With[{w = 800, h = 600},
Graphics[Raster[
Table[Boole[PrimeQ[w i + j + 1]], {i, 0, h - 1}, {j, 0, w - 1}]]]]
 

Related to How to Create a Prime Number Image in Mathematica?

1. What is "Prime Plotting" in Mathematica?

"Prime Plotting" in Mathematica refers to the process of creating plots and graphs that display the distribution of prime numbers. This can be done using the built-in functions and tools in Mathematica, or by writing custom code using its programming language.

2. Why is "Prime Plotting" important?

"Prime Plotting" is important because it allows us to visually analyze and understand the distribution of prime numbers. This can help us identify patterns and properties of prime numbers, which can have significant implications in fields such as cryptography and number theory.

3. What are the main features of Mathematica for "Prime Plotting"?

Mathematica has a variety of built-in functions and tools specifically designed for "Prime Plotting", such as PrimeQ, PrimePi, and PrimeNu. It also has the ability to generate plots and graphs in various styles and formats, allowing for a customizable and visually appealing representation of prime number distribution.

4. Can Mathematica be used for both simple and complex "Prime Plotting" tasks?

Yes, Mathematica can be used for both simple and complex "Prime Plotting" tasks. It has a user-friendly interface for basic plotting tasks, but also has advanced features and functions for more complex tasks, such as analyzing large sets of prime numbers or creating interactive plots.

5. Are there any resources available for learning "Prime Plotting" in Mathematica?

Yes, there are many resources available for learning "Prime Plotting" in Mathematica. The official Mathematica website has tutorials, documentation, and community forums dedicated to "Prime Plotting" and other mathematical topics. There are also numerous online tutorials, books, and courses available for learning how to use Mathematica for "Prime Plotting".

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
313
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Astronomy and Astrophysics
7
Replies
226
Views
11K
Replies
1
Views
956
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top