Introduction

In 1742, the Prussian mathematician Christian Goldbach wrote a letter to Leonhard Euler with a curious observation. Take any even number bigger than 2 — say 8, or 100, or 1,000,000 — and you can always write it as the sum of two prime numbers: 8 = 3 + 5, 100 = 3 + 97, and so on.

Try it yourself with a few numbers and you will never fail. 4 = 2 + 2. 6 = 3 + 3. 28 = 11 + 17. The bigger the number, the more ways there usually are to split it.

And yet, after nearly three centuries, nobody has proved it must always work — and nobody has found a single even number that breaks it. That gap, between "it always seems to happen" and "we can prove it always happens," is exactly where some of the deepest difficulty in mathematics lives.

Try It Yourself

Pick any even number greater than 2. The demo searches every prime p and checks whether n − p is also prime — listing all the pairs at once.

<p class="hint">Pick any even number greater than 2. The demo searches for a pair of primes <b>p + q = n</b> — and counts <b>every</b> such pair. Goldbach's conjecture says a pair <i>always</i> exists. Nobody has ever found a counterexample, yet nobody has proved it can't happen.</p>
<div class="row">
  <button id="dec" type="button" class="ghost">−2</button>
  <div class="num" id="num">100</div>
  <button id="inc" type="button" class="ghost">+2</button>
</div>
<div class="btns">
  <button id="find" type="button">Find prime pairs</button>
  <button id="rand" type="button" class="ghost">Random even n</button>
</div>
<div class="status" id="status">Press "Find prime pairs".</div>
<ul class="pairs" id="pairs"></ul>
<div class="comet-wrap">
  <div class="comet-title">Goldbach comet — number of prime pairs for each even n</div>
  <canvas id="comet" width="520" height="200"></canvas>
</div>
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; color: #222; margin: 0; }
.hint { font-size: .9rem; color: #444; margin: 0 0 .8rem; line-height: 1.45; }
.row { display: flex; align-items: center; gap: .8rem; margin: .3rem 0; }
.num { font: 800 30px ui-monospace, monospace; color: #1d3557; min-width: 110px; text-align: center; }
.btns { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
button { font: 600 14px system-ui, sans-serif; padding: .45rem .9rem; border: 1px solid #1d3557;
         background: #1d3557; color: #fff; border-radius: 8px; cursor: pointer; }
button.ghost { background: #fff; color: #1d3557; }
button:disabled { opacity: .5; cursor: default; }
.status { font-size: 1rem; font-weight: 600; margin: .5rem 0; min-height: 1.4em; }
.status.ok { color: #0a7d33; }
.status.bad { color: #c92f3c; }
.pairs { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: .4rem 0 1rem; }
.pairs li { background: #e8eef3; color: #1d3557; border: 1px solid #cdd9e3; border-radius: 6px;
            padding: .25rem .55rem; font: 600 13px ui-monospace, monospace; }
.comet-wrap { margin-top: .6rem; }
.comet-title { font-size: .78rem; color: #667; margin-bottom: .3rem; }
canvas { width: 100%; max-width: 520px; height: auto; background: #f6f8fa; border: 1px solid #dde3ea; border-radius: 8px; }
const fmt = (s, v) => s.replace(/%(\w+)%/g, (_, k) => String(v[k] ?? ''));
// Goldbach's conjecture (Christian Goldbach, 1742): every even integer n > 2 can be written as the sum of two primes. Still OPEN — verified by computer for every even n up to 4 x 10^18, but never proved. This demo, for a given even n, lists every prime pair p + q = n (p <= q) and plots how the *number* of such pairs grows — the famous "Goldbach comet".
const MAXN = 100000;
// Sieve of Eratosthenes up to MAXN.
const isPrime = new Uint8Array(MAXN + 1).fill(1);
isPrime[0] = isPrime[1] = 0;
for (let i = 2; i * i <= MAXN; i++) if (isPrime[i])
  for (let j = i * i; j <= MAXN; j += i) isPrime[j] = 0;

// All prime pairs p + q = n with 2 <= p <= q.
function goldbachPairs(n){
  const out = [];
  for (let p = 2; p <= n / 2; p++)
    if (isPrime[p] && isPrime[n - p]) out.push([p, n - p]);
  return out;
}

let n = 100;
const $ = id => document.getElementById(id);
function setNum(v){ n = Math.max(4, Math.min(MAXN, v)); if (n % 2) n++; $('num').textContent = n; }
function setStatus(t, cls){ const s = $('status'); s.textContent = t; s.className = 'status ' + (cls||''); }

function find(){
  const pairs = goldbachPairs(n);
  const ul = $('pairs'); ul.innerHTML = '';
  const show = pairs.slice(0, 24);
  show.forEach(([p, q]) => { const li = document.createElement('li'); li.textContent = p + ' + ' + q; ul.appendChild(li); });
  if (pairs.length > show.length){ const li = document.createElement('li'); li.textContent = fmt('+%v% more', { v: pairs.length - show.length }); ul.appendChild(li); }
  if (pairs.length > 0){
    setStatus(fmt('✓ %n% = sum of two primes in %length%%v%', { n: n, length: pairs.length, v: pairs.length===1?' way. As Goldbach predicted.':' ways. As Goldbach predicted.' }), 'ok');
    console.log(fmt('%n%: %length% representations, e.g. %v%+%v2%', { n: n, length: pairs.length, v: pairs[0][0], v2: pairs[0][1] }));
  } else {
    setStatus('No pair found — this would be a counterexample!', 'bad');
  }
  drawComet();
}

function drawComet(){
  const cv = $('comet'), ctx = cv.getContext('2d');
  const W = cv.width, H = cv.height, pad = 24;
  ctx.clearRect(0, 0, W, H);
  // Window of even numbers centred near n.
  const lo = 4, hi = Math.min(MAXN, Math.max(300, n + 100));
  let maxCount = 1;
  const pts = [];
  for (let m = lo; m <= hi; m += 2){ const c = goldbachPairs(m).length; if (c > maxCount) maxCount = c; pts.push([m, c]); }
  // axes
  ctx.strokeStyle = '#c3ccd6'; ctx.lineWidth = 1;
  ctx.beginPath(); ctx.moveTo(pad, H - pad); ctx.lineTo(W - 6, H - pad); ctx.moveTo(pad, 6); ctx.lineTo(pad, H - pad); ctx.stroke();
  const x = m => pad + (m - lo) / (hi - lo) * (W - pad - 8);
  const y = c => (H - pad) - c / maxCount * (H - pad - 8);
  ctx.fillStyle = '#1d3557';
  for (const [m, c] of pts){ ctx.beginPath(); ctx.arc(x(m), y(c), 1.4, 0, 7); ctx.fill(); }
  // highlight current n
  const cn = goldbachPairs(n).length;
  ctx.fillStyle = '#e63946'; ctx.beginPath(); ctx.arc(x(n), y(cn), 4, 0, 7); ctx.fill();
  ctx.fillStyle = '#667'; ctx.font = '11px system-ui';
  ctx.fillText('pairs', pad + 4, 12); ctx.fillText('n', W - 16, H - pad + 14);
}

$('inc').addEventListener('click', () => { setNum(n + 2); });
$('dec').addEventListener('click', () => { setNum(n - 2); });
$('find').addEventListener('click', find);
$('rand').addEventListener('click', () => { setNum(6 + 2 * Math.floor(Math.random() * 300)); find(); });
setNum(100); drawComet();
Result
Console

Two things stand out. First, you will always find at least one pair, no matter which even number you try. Second, the number of pairs tends to climb as the numbers grow — the scattered cloud below is the famous Goldbach comet. Verifying any single number is quick; proving the pattern never breaks, for the infinitely many numbers we can never test, is the part nobody has managed.

The Real Difficulty

How hard is Goldbach's conjecture, really? Its statement fits on one line, but its status is OPEN — unproved and undisproved since 1742.

  • Checking one number is easy. To test a single even n, just scan primes up to n/2 and see if any pairs with another prime. Fast, mechanical, done.
  • Computers have checked an astronomical range. As of today, every even number up to 4 × 101810^{18} has been verified — that is four quintillion cases, all of them satisfying the conjecture. Not one counterexample.
  • But checking is not proving. There are infinitely many even numbers. No amount of finite testing rules out a giant counterexample lurking beyond our reach. A proof must cover them all at once.
  • The "weak" version is settled. In 2013, Harald Helfgott proved the weak Goldbach conjecture: every odd number above 5 is a sum of three primes. The strong even version remains unconquered.

This is the opposite face of difficulty from a problem like P vs NP: there, we cannot even verify a quick solution. Here, verification is trivial — it is the universal proof, true for every one of infinitely many cases, that has resisted the greatest mathematicians for 280 years.

Where It Matters

Goldbach's conjecture is "pure" mathematics, but the chase after it has built tools that reach far beyond it:

  • Understanding the primes. Attacking Goldbach forces deep questions about how primes are spread out — the heart of analytic number theory.
  • Sieve methods. Techniques invented to bound prime pairs (like Chen Jingrun's 1973 result that every large even number is a prime plus a number with at most two prime factors) are now standard tools across number theory.
  • Cryptography's foundation. The same hard facts about primes that make Goldbach elusive are what let primes secure modern encryption — see Is N prime?.
  • A model of mathematical risk. Goldbach is the textbook example of why mathematicians distrust "it holds for the first trillion cases" and demand a proof instead.

Chasing a one-line conjecture has, over centuries, sharpened the entire machinery we use to reason about whole numbers.

Conclusion

Goldbach's conjecture is a small miracle of mathematics: a claim a ten-year-old can understand, confirmed in every one of four quintillion tested cases, and still not proven after 280 years. The numbers keep splitting into primes, exactly as Goldbach guessed — but mathematics asks for certainty across infinity, not just overwhelming evidence.

So the next time the demo finds pair after pair without ever failing, hold both thoughts at once: the pattern looks unbreakable, and we genuinely do not know that it is. That tension — between what we can see and what we can prove — is the same one driving P vs NP and the deepest open questions in all of computation.

Share this article

Pick a channel — or use your device's native share sheet.

Comments

Loading comments...

https://www.kipuhub.com/en/article/goldbach-conjecture/Content licensed under CC BY-NC 4.0.