Preface
Mathematics is often described as a language. Some have even called it the language of nature. Nature is very beautiful and is inspiration for art. Does this mean that mathematics is also a language for art and beauty? I think we should try to find out!
The math-art relationship is shown from a study of the Fibonacci sequence. If you divide a value in the sequence by its predecessor, you get an approximate value of 1.618 (*Note: it approaches this value as you go higher in the sequence). This value is called the Golden Ratio. It is found in nature as it is in art and architecture.
In nature you can see it in the structure of the nautilus seashell or the spiral of a pinecone. In art, da Vinci’s paintings show a balance that approximates the Golden Ratio. In architecture, it is also called the Divine Proportion. Structural design often uses this value as placement of windows and doors. There are many examples to be discovered. I will give you a place to start with here:
Are These 10 Natural Occurrences Examples of the Fibonacci Sequence? By Katie Liu – https://www.discovermagazine.com/are-these-10-natural-occurrences-examples-of-the-fibonacci-sequence-46574
Fractals are also shown as an example of a trippy-type of math-art. The patterns go on forever in a complex but a repeating pattern. One could gaze at such works as the Mandelbrot Set and keep finding new and more interesting views.
There are still other examples where mathematics can create beautiful artwork. In this article, we are going to talk about an area that doesn’t get the attention it deserves in art. We are going to discuss creating art with Prime Numbers.
Introduction
This article is about a creative exploration of Prime Numbers. I will provide a basic definition of prime numbers to start. There will then be some exploration to see if art can be created from primes. From there, we will dive slightly deeper into other areas of prime numbers. The layout will be similar in each section. Start with a definition and then experiment. My hope is that this entices you to dive further and share your results with everyone. The world of mathematics is always growing and could use more open minds.
What is a Prime Number?
Let’s provide a quick, simple definition of prime numbers. Simply put, a prime number is a natural number greater than 1 that is exactly divisible only by itself and 1. As an example, the number 5 is only divisible by 5 or 1. As an example of a non-prime, we have 4 since it is divisible by 2 as well as itself and 1.
Putting the definition to work, here is a simple sequence of prime numbers.
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 and on from there!
Generation of prime numbers is also an area of interest. You could just brute force the sequence till you run into the limits of available computing power (Yes, there are limits to computing power). There have been advancements in this topic throughout the years. You can read more about them here:
Sieve of Eratosthenes – https://cp-algorithms.com/algebra/sieve-of-eratosthenes.html
Primality Tests – https://cp-algorithms.com/algebra/primality_tests.html
You may have some fun trying to improve upon these methods. Be centered and aware that there are many, well-experienced minds working on this problem every day. That said, you never know what could happen if you try. Maybe you can be the person who pushes past the current limitations.
Please keep in mind that this is merely the beginning of a large area of study. Primes are an essential part of number theory. There are also other dependent areas in STEM fields. An example is in acoustical engineering. Schroeder Diffusers are used in recording studios to eliminate echo but not disrupt the true sound wave. This is developed by using prime numbers in calculations. If interested, look-up the formula for Well Depth (Quadratic Residue Diffusers explained https://ateliercrescendo.ac/quadratic-residue-diffusers-qrds-explained-theory-design-for-concert-halls-theatres-studios/ ).
Again, this is a beginning point to the fascinating world of number theory. We will look at another implementation. Cryptography quickly comes to mind. The notion of creating an encryption key requires the generation of prime numbers. These are often factored together to create unique keys. If the key is not generated properly then the security will be lacking.
Let’s take it a step further. We can break down non-primes using primes. For every non-prime, natural number we can represent it as a product of primes. Take 4 as an example of a non-prime. This is a product of the prime number 2 multiplied by another 2. These non-primes are called composites.
We will now talk about what these numbers look like when plotted out. I’ll start with a simple plot. The Y-axis will be the generated prime number and the x-axis simply the index value in the sequence. For interested folks, I am using Python with matplotlib for graphs. Prime Number Sequences are generated with either the SymPy library or with a bespoke function (depending on the day).
Here is the resulting plot:

Now that looks pretty boring. Even though it’s not perfect linear, we can see the progression. This article is not going to be about data analysis. We’re trying to make some art out of this sequence. Let’s try a polar co-ordinate system for the sequence and see what happens.

That’s a bit more interesting but still a distance to go from being considered artwork (at least by me). Let’s see what can be found in the history book of prime studies.
Ulam Spiral
The Mathematician Stanislaw Marcin Ulam provides an interesting view of prime numbers. In 1963, he created a pattern for prime numbers following a spiral shape. The story of its creation takes place during a scientific presentation. He arranged the list of integers going counter clockwise in a boxy pattern. Here you can see that plot:

When you take away the non-primes, you can note certain patterns in the arrangement. You will need to look abstractly to get it. More specifically, the primes can be shown to concentrate on the diagonals. Here is the resulting plot at a basic level:

You can see how the diagonals have primes. If that is not entirely clear, we build the spiral with a very large number of values. Hopefully, you can see how concentrated the plot gets. Take a look here:

Notice the diagonal pattern. Stepping back, we can see a bit of an art to it. Let’s make it more interesting and experiment with the concept. First, instead of straight lines, we’ll use arcs. They will go in between the points. You now get a neat looking pattern:

That looks a little like a flower of sorts. Taking a step in a different direction, how about mirroring the spirals and create more colors. We’ll enhance the points. Also, take away the arc-ing lines. This should be a good experiment. This is what results:

That’s really looking like math-art! I like the expansion pattern. It is similar to a double helix. Let’s move on to another area of primes.
Prime Factors
We talked about composite numbers above. Recall that factors are when you take any given number and break it down into a product of primes. Taking 24 as an example, we can break that down into the following product:
2 x 2 x 2 x 3 = 24
Of course, we can make a plot out of this! Whether or not it results in art is in the eye of the beholder. Let’s try it out. We’ll assign colors to the primes and draw as a circle. Here are some examples:


The next step is to combine these together to form other numbers. Here is an example of 24:

You can see the combination of 2’s with a 3 to graphically form the value 24. There is the possibility of really getting complex patterns with different values. What if we take a series of 100 numbers and graphically factor each one. This is what results:

That’s a pretty cool layout! I can see this as a good form of artwork. It would need more intricate choice of coloring as the values go up. Maybe you could take this one and combine in a spiral to get something very interesting! Moving forward, we will explore another area of prime numbers and art.
Prime Number Gap
There is another part of prime numbers that could give an artsy view. The prime number gap is defined as the difference between 2 successive primes. If we take 2 and 3, that results in a gap of 1. Taking the next difference of 3 and 5 leads to a gap of 2 (aka a twin prime). This goes on where gaps can get larger or shorter. There are studies of this sequence where mathematicians find patterns. Where there are patterns, we could find some art.
The following is a plot showing the prime gaps laid out into a series. This is to give us a view of the values we are working with:

Not too exciting either but there are some interesting patterns there. Recognize the number of even and odd gaps? Do you notice the odd gap? Why is it so lonely? Are there patterns in the gaps to notice? If you are interested in more study, lookup Polignac’s Conjecture, Hardy-Littlewood First Conjecture, and Cramér’s Conjecture. That will lead you onto some deep work. What about we try the polar co-ordinates again with this sequence?

I like the look but let’s try something more dynamic. Have you seen string art (or Mandala Art)? We’ll go for something along those lines.
Network graphs have a look like string art. We’ll make a network out of the prime number and gap sequence. We’ll arrange the primes into a layered-pinwheel-like pattern. The numbers will be connected in sequence in a non-directional fashion. In other words, node 2 will connect to node 3 which will connect to node 5 and so on.
Each layer (or clique) is representative of a gap and has its own color. The base 2 will be white to keep it simple. This goes on for all values in the set. What does it give us in the end? Take a look here:

That looks very cool! It did take experimentation to get it into this shape. That’s fine as it’s always a part of the learning process. For a more interesting work of art, we step up the number of generated values in the sequence. The resulting graph is as follows:

That’s taking it to another level! I’m very pleased with this result. I’ll even give it a name and call it the “prime eye.”
Further Reading
I hope this encourages you to explore prime numbers in art more. If you scour papers and internet you can find some interesting publications. Here are some for you to get started (be sure to look through the references as well for more works):
Abstracts: The Prime Number Series by Joel Arnstein – https://joelarnsteinartist.co.uk/paintings/abstracts-the-prime-number-series/
Prime concerns: painting number patterns by Paul Ashwell – https://www.tandfonline.com/doi/full/10.1080/17513472.2020.1734427
Poetry is a type of art and this article has some interesting input on primes:
Ode to Prime Numbers by Sarah Glaz – https://www.americanscientist.org/article/ode-to-prime-numbers
Finally
Art comes in many forms and expressions. I presented a relationship between the language of nature and creativity. We all have a special take on the world but a unifying point is language and communication. If we combine the fields in the right manner we have a form of expression that we can share with the world.
In some ways, working with math is like wielding a paintbrush. We see the numbers and how they land on the canvas. There are many patterns to explore. Some are chaotic while others are more ordered. There are many that are in harmony with all around us. I leave that up to you to discover.
If this is your introduction into prime numbers, I hope it provided a good starting point. In the current landscape of AI, I believe now is a time more than ever for the study of mathematics. It is one thing for us to plug a question into a model and get a summarization from someone else’s work. It is another thing for us to actual understand the underpinnings of it all.
Be creative and always be open to learning something new!
Thank you and have a great day!
Appendix
References
[1] Calculator Soup. Prime Factorization Calculator. Retrieved from: https://www.calculatorsoup.com/calculators/math/prime-factors.php
[2] Elham Razzazi, Seyed kazem Mousavi. Arizona State University. Retrieved from: Prime Number Distribution via Digital Roots and Logarithmic Spirals. Retrieved from: https://www.researchgate.net/publication/400405619_Prime_Number_Distribution_via_Digital_Roots_and_Logarithmic_Spirals
[3] Geeks for Geeks. Prime factors of a number. Retrieved from: https://www.geeksforgeeks.org/dsa/print-all-prime-factors-of-a-given-number/
[4] Grant Sanderson. 3Blue1Brown. Why do prime numbers make these spirals? Retrieved from: https://www.3blue1brown.com/lessons/prime-spirals/
[5] Numberphile. Prime Spirals. Retrieved from: https://www.youtube.com/watch?v=iFuR97YcSLM
[6] Peter Bissonnet. Do Prime Numbers Obey a Three Dimensional Double Helix? Retrieved from: https://vixra.org/abs/1606.0310
[7] Stoyan R Vezenkov. Center for Applied Neuroscience Vezenkov. The Double Helix Model of Primes: No Divisions, No Probabilities, Structures in the Chaos. Retrieved from: https://www.researchgate.net/publication/393045056_The_Double_Helix_Model_of_Primes_No_Divisions_No_Probabilities_Structures_in_the_Chaos
[8] Tarnowskie Góry. Distribution of the Prime Numbers. Retrieved from: https://vixra.org/pdf/1902.0406v1.pdf
[9] That’s Maths. Spiralling Primes. Retrieved from: https://thatsmaths.com/2019/09/12/spiraling-primes/
[10] Wolfram. Spiral of Primes. Retrieved from: https://demonstrations.wolfram.com/SpiralOfPrimes/
Code
*Important Note: All code is in AS-IS state. Code has been created from examples in the sources as well as personal additions. Use at your own risk.
Code for double spiral
import matplotlib.pyplot as pltimport numpy as npdef generate_primes(limit): # Returns a list of prime numbers up to the specified limit using a sieve. sieve = [True] * limit sieve[0] = sieve[1] = False for index in range(2, int(limit**0.5) + 1): if sieve[index]: for j in range(index * index, limit, index): sieve[j] = False return [i for i, is_p in enumerate(sieve) if is_p]def plot_2d_expanding_prime_spiral(num_primes=600): # Generates a 2D dual spiral from primes where dot size increases with value. # 1. Generate prime numbers upper_limit = int(num_primes * np.log(num_primes) * 1.2) + 100 primes = np.array(generate_primes(upper_limit)[:num_primes]) # 2. Geometric Core Parameters # In 2D polar coordinates, we use Archimedean scaling where radius tracks value theta_factor = 0.55 # Controls the tightness of the spiral winding radius_factor = 0.1 # Controls how quickly the spiral expands outward # 3. Dynamic Node Sizing (Graphical circle expands as prime value increases) min_marker_size = 4 max_marker_size = 120 normalized_sizes = (primes - primes.min()) / (primes.max() - primes.min()) marker_sizes = min_marker_size + ( normalized_sizes * (max_marker_size - min_marker_size) ) # 4. Generate Coordinates for Primary Spiral (Series 1) # Theta grows linearly with the prime value, causing it to wrap around theta_1 = primes * theta_factor r = primes * radius_factor x_1 = r * np.cos(theta_1) y_1 = r * np.sin(theta_1) # 5. Generate Coordinates for Mirrored Spiral (Series 2) # Adding np.pi (180 degrees) mirrors the path directly opposite to Series 1 theta_2 = theta_1 + np.pi x_2 = r * np.cos(theta_2) y_2 = r * np.sin(theta_2) # 6. Render 2D Canvas plt.figure(figsize=(10, 10), facecolor="black") ax = plt.gca() ax.set_facecolor("black") # Plot Series 1 (Expanding Cyan/Cool Nodes) plt.scatter( x_1, y_1, c=primes, cmap="cool", s=marker_sizes, alpha=0.6, edgecolors="white", linewidths=0.2, label="", zorder=2, ) plt.plot(x_1, y_1, c="cyan", alpha=0.15, linewidth=1, zorder=1) # Plot Series 2 (180° Mirror - Expanding Magenta/Spring Nodes) plt.scatter( x_2, y_2, c=primes, cmap="spring", s=marker_sizes, alpha=0.6, edgecolors="white", linewidths=0.2, label="", zorder=2, ) plt.plot(x_2, y_2, c="magenta", alpha=0.15, linewidth=1, zorder=1) # Aesthetics and Styling plt.title( "Neat Prime Spiral", color="white", fontsize=14, pad=15, ) # Force an equal aspect ratio so the circles and spiral don't look stretched ax.set_aspect("equal", adjustable="box") # Clean up gridlines and adjust axes colors for dark mode visualization ax.tick_params(colors="gray") ax.grid(True, color="dimgray", linestyle=":", alpha=0.3) plt.show()if __name__ == "__main__": plot_2d_expanding_prime_spiral(num_primes=500)
Code for Prime Eye
import matplotlib.pyplot as pltimport networkx as nximport numpy as npdef get_primes_up_to(limit): # Returns a list of prime numbers up to a given limit. primes = [] for num in range(2, limit + 1): is_prime = True for i in range(2, int(num**0.5) + 1): if num % i == 0: is_prime = False break if is_prime: primes.append(num) return primes# --- Configuration ---MAX_NUMBER = 30000 # Increased limit for a denser spiral bloomprimes = get_primes_up_to(MAX_NUMBER)# Calculate prime gapsprime_gaps = {}for i in range(1, len(primes)): current_prime = primes[i] prev_prime = primes[i-1] prime_gaps[current_prime] = current_prime - prev_primeprime_gaps[2] = 0 # Center node# Color palette for prime gapsgap_colors = { 0: "#FFFFFF", # Center core 1: "#FFD700", # Gold 2: "#FF1493", # Deep Pink (Twin Primes) 4: "#FF4500", # Orange Red (Cousin Primes) 6: "#9400D3", # Violet (Sexy Primes) 8: "#00FF7F", # Spring Green 10: "#00FFFF", # Cyan 12: "#FF8C00", # Dark Orange 14: "#4169E1" # Royal Blue}default_gap_color = "#FF69B4"# Group primes by gap sizegap_groups = {}for p in primes: g = prime_gaps[p] if g not in gap_groups: gap_groups[g] = [] gap_groups[g].append(p)unique_gaps = sorted([g for g in gap_groups.keys() if g != 0])num_petals = len(unique_gaps)# --- Spiral Geometric Calculation ---pos = {}pos[2] = (0.0, 0.0) # Plant core at center# Controls the intensity of the spiral curve (in radians per step)TWIST_RATE = 0.12for petal_index, gap_size in enumerate(unique_gaps): # Base angle for this specific petal family base_angle = (2 * np.pi * petal_index) / num_petals gap_groups[gap_size].sort() for distance_index, p in enumerate(gap_groups[gap_size]): # Distance scales outward smoothly radius = 1.5 + (distance_index * 0.6) + (0.01 * (distance_index ** 2)) # Add the natural spiral twist based on the distance index twisted_angle = base_angle + (distance_index * TWIST_RATE) # Convert to standard X, Y coordinates x = radius * np.cos(twisted_angle) y = radius * np.sin(twisted_angle) pos[p] = (x, y)# Build GraphG = nx.Graph()for p in primes: G.add_node(p, color=gap_colors.get(prime_gaps[p], default_gap_color))# Thread sequential vine linesfor i in range(len(primes) - 1): G.add_edge(primes[i], primes[i+1])# --- Rendering ---fig, ax = plt.subplots(figsize=(12, 12))ax.axis("off")fig.patch.set_facecolor('#0B0C10') # Dark background# Draw sequential connecting linesnx.draw_networkx_edges(G, pos, ax=ax, edge_color="#ECF1F3", width=1.0, alpha=0.5)# Draw prime nodesnode_colors = [G.nodes[n]['color'] for n in G.nodes()]nx.draw_networkx_nodes(G, pos, ax=ax, node_color=node_colors, node_size=350, edgecolors="#111111", linewidths=1, alpha=0.95)# Draw number labelslabels = {n: str(n) for n in G.nodes()}nx.draw_networkx_labels(G, pos, labels, ax=ax, font_size=6.5, font_weight="bold", font_color="#000000", font_family="sans-serif")plt.title("Prime Gap Pinwheel Mandala Art", color="#66FCF1", fontsize=18, fontweight="bold", pad=20)plt.tight_layout()plt.show()

You must be logged in to post a comment.