Goldbach's Conjecture is one of the oldest and most stubbornly mysterious puzzles in the world of numbers. It says:
Every even number greater than 2 can be written as the sum of two prime numbers.
Sounds simple, right? But don’t be fooled — despite centuries of trying, nobody has cracked a full proof yet!
Examples:
4 = 2 + 2
6 = 3 + 3
8 = 3 + 5
10 = 5 + 5 (or 3 + 7, if you’re feeling fancy)
Try it yourself on any even number — chances are you’ll find at least one pair of primes that work!
Back in 1742, the German mathematician Christian Goldbach scribbled this idea in a letter to none other than Leonhard Euler — the rockstar mathematician of the 18th century.
Goldbach’s original idea involved three primes, but Euler polished it into the cleaner "two primes" form we know today. Mathematicians and computers have checked this for insanely huge numbers and it still holds up. Yet, a formal proof? Still waiting. (Seriously, where’s the proof??)
Prime numbers are the atoms of math — the building blocks of every whole number — and Goldbach’s Conjecture is like the secret handshake between addition and primes. Solve this, and you might just be the next math legend!
GoldbachCconjecture/
│
├── core/
│ ├── main.py
│ ├── primes.py # Prime generation and Goldbach pair logic
│
├── images/
│ ├── *.png
│ ├── *.png
│
├── prime_pair_constellations.py # Visualization 1
├── goldbach_spiral.py # Visualization 2
├── prime_pair_heatmap.py # Visualization 3
│
├── requirements.txt
├── README.md
You can choose the maximum number up to which you want to explore Goldbach's Conjecture(in main.py).
- The scripts will automatically generate all primes up to your chosen limit.
- All even numbers in that range will be tested for prime pairs.
- Visualizations adjust automatically to your chosen limit, keeping plots readable and fun.
There are three visualization scripts — pick one to run:
-
Prime Pair Constellations (
prime_pair_constellations.py)- An interactive scatter plot of prime pairs where the point's position is (p1, p2). Hover over a point to see the prime pair and their even sum.
-
Goldbach Spiral (
goldbach_spiral.py)- Even numbers are plotted along a spiral, with the size and color of each point indicating the number of Goldbach pairs it has.
-
Prime Pair Heatmap (
prime_pair_heatmap.py)- This visualization generates a heatmap showing the frequency of each prime number's appearance in Goldbach pairs up to a given limit.
Usage:
- Clone the repo:
git clone https://github.com/PritamTheCoder/GoldbachConjecture.git- Navigate to main directory:
cd core- Install requirements:
# Create a virtual environment
python -m venv venv
# Activate the virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
# Install the dependencies from the requirements.txt file
pip install -r requirements.txt- Run the main script:
python main.pyYou’ll be prompted to enter the maximum even number limit, and the choice of visualization.
If you try this, beware of the sneaky primes hiding in the shadows - like 2, the only even prime (talk about being special!). Also, don’t forget: the universe of primes is infinite, but your computer’s patience might not. Choose your limits wisely!
A plot showing even numbers on a spiral, with point size and color indicating the number of Goldbach pairs it has.
An interactive scatter plot of prime pairs where the color of each point corresponds to their even sum.
A heatmap showing how frequently each prime appears in Goldbach pairs up to a given limit.
This project lets you test Goldbach's Conjecture for all even numbers up to a limit of your choice. It’s a fun way to blend classical math with the magic of programming.
Happy coding - may your primes always add up!



