Foreword

What's a semiprime sandwich

Years ago, after a casual conversation with my friend Chai about aging and powers of 2 (specifically 252^5), I stumbled on a neat observation:

33=311,34=217,35=57.33 = 3 \cdot 11,\qquad 34 = 2 \cdot 17,\qquad 35 = 5 \cdot 7.

The numbers 33,34,3533, 34, 35 were all consecutive, distinct semiprimes. And it begged the question: what is the longest possible chain of consecutive semiprimes? (Spoiler alert: it’s 3).

Ok before we continue, some vocab to job our memories.

A semiprime is a product of exactly two primes. The two primes can be equal (25=5525 = 5 \cdot 5) or different (15=3515 = 3 \cdot 5).

A distinct semiprime is the second case: two different primes. So is 15 a distinct semiprime? Yes! Is 25 a distinct semiprime? No. For the purposes of this section, I say “semiprime” without qualifying it I mean the distinct kind. The non-distinct kind (squares of primes) breaks half the patterns we’re about to consider, so I’ll mostly ignore it.

A semiprime sandwich 🥪 is what I call sequences such as (33,34,35)(33, 34, 35). Consecutive, distinct semiprimes, of length 3 (which, as we will show soon enough, is the longest possible chain of consecutive semiprimes. And the first occurance of such a sequence happens to be: (33,34,35)(33, 34, 35).

why three is the ceiling

Time to actually show why 3 is the max. Note: I’m not labeling this a proof. The reasoning below stays pretty informal, but it’s tight enough to convince.

The claim: there’s no four consecutive integers (n,n+1,n+2,n+3)(n, n+1, n+2, n+3) where every one of them is a distinct semiprime.

Two cases to consider, depending on whether we anchor on an odd or even distinct semiprime.

Case 1: nn is an odd distinct semiprime. Both neighbors n1n - 1 and n+1n + 1 are even.

Now suppose n1n - 1 is also a distinct semiprime. The only way an even number is a distinct semiprime is for its factorization to look like 2a2 \cdot a for some odd prime aa. So n1=2an - 1 = 2a, which means n=2a+1n = 2a + 1.

Look at n+1n + 1. It’s 2a+2=2(a+1)2a + 2 = 2(a + 1). But aa is an odd prime, so a+1a + 1 is even, which means n+1=2(even)n + 1 = 2 \cdot (\text{even}), and that’s divisible by 4. A distinct semiprime can’t be divisible by 4: that puts 222^2 in the factorization (the prime 2 appearing twice), which breaks “distinct.”

So n+1n + 1 is not a distinct semiprime. The takeaway: given nn an odd distinct semiprime, either n1n - 1 or n+1n + 1 is a distinct semiprime, but not both.

Case 2: nn is an even distinct semiprime. Same logic as above: the only way an even number is a distinct semiprime is n=2kn = 2k where kk is an odd prime.

Look at n2=2k2=2(k1)n - 2 = 2k - 2 = 2(k - 1). Since kk is an odd prime, k1k - 1 is even, so n2n - 2 is divisible by 4. Same kill, can’t be a distinct semiprime.

By the same logic, n+2=2(k+1)n + 2 = 2(k + 1) is divisible by 4 too. So neither n2n - 2 nor n+2n + 2 is a distinct semiprime.

Putting it together. Among any four consecutive integers, exactly one of them is divisible by 4 (residues mod 4 cycle through {0,1,2,3}\{0, 1, 2, 3\}, hitting each one once). That divisible-by-4 slot can’t be a distinct semiprime. Case 1 catches it if we anchored on an odd, Case 2 catches it if we anchored on an even. Either way the chain breaks at that slot.

So no four-in-a-row, and the max chain length is 3. ∎

By the way: a useful side effect of the proof is that the middle slice of any sandwich is always the even one. The two outside slices are odd (each a product of two different odd primes), and the middle is the unique even distinct semiprime in the triple.

That smallest sandwich (33,34,35)(33, 34, 35) also happens to land in a real chunk of human ages. So if you’re 33, 34, or 35 right now: you’re literally inside a sandwich. (Next sandwich birthday after that? See Puzzle 2 below. Heads up: it’s a long wait.)

Five puzzles. They get harder.

~ puzzle 1: sharpen the middle ~

The middle of a sandwich is even. Sharpen that: show the middle is actually 2p2p for some odd prime pp. Then show p17p \geq 17 by walking through small primes.

~ show solution ~ ~ hide solution ~

Middle is 2p2p. The middle is a distinct semiprime and even, so 2 is one of its two primes. The other prime has to be different from 2, so it’s odd. Call it pp. Middle is 2p2p with pp an odd prime.

p17p \geq 17. Walk through small odd primes:

pp2p2ptriplewhat kills it
36(5,6,7)(5, 6, 7)5 and 7 are primes
510(9,10,11)(9, 10, 11)9=329 = 3^2, 11 prime
714(13,14,15)(13, 14, 15)13 prime
1122(21,22,23)(21, 22, 23)23 prime
1326(25,26,27)(25, 26, 27)25=5225 = 5^2, 27=3327 = 3^3
1734(33,34,35)(33, 34, 35)nothing kills it ✓

First pp that survives is 17. Smallest sandwich is (33,34,35)(33, 34, 35). Anything smaller has at least one outer slice that’s a prime, a prime power, or otherwise not a distinct semiprime.

~ puzzle 2: when's your next sandwich birthday? ~

Find the next two sandwiches after (33,34,35)(33, 34, 35) by hand. No spreadsheets.

~ show solution ~ ~ hide solution ~

Middle is 2p2p with pp odd prime 17\geq 17 (Puzzle 1). Walk candidate middles above 34 and check whether the two odd neighbors are both distinct semiprimes:

middletripleresult
38=21938 = 2 \cdot 19(37,38,39)(37, 38, 39)37 prime ✗
46=22346 = 2 \cdot 23(45,46,47)(45, 46, 47)45=32545 = 3^2 \cdot 5
58=22958 = 2 \cdot 29(57,58,59)(57, 58, 59)59 prime ✗
62=23162 = 2 \cdot 31(61,62,63)(61, 62, 63)61 prime ✗
74=23774 = 2 \cdot 37(73,74,75)(73, 74, 75)73 prime ✗
82=24182 = 2 \cdot 41(81,82,83)(81, 82, 83)81=3481 = 3^4
86=24386 = 2 \cdot 43(85,86,87)(85, 86, 87)85=51785 = 5 \cdot 17, 87=32987 = 3 \cdot 29

Next sandwich: (85,86,87)(85, 86, 87).

Keep going:

| 94=24794 = 2 \cdot 47 | (93,94,95)(93, 94, 95) | 93=33193 = 3 \cdot 31, 95=51995 = 5 \cdot 19 ✓ |

Sandwich after that: (93,94,95)(93, 94, 95).

So if you’re stuck at 33–35 right now, your next sandwich birthdays are 85–87, then 93–95. About 50 years to the next one, then a quick 8 years to the one after. Sandwiches don’t space out evenly. They cluster in surprising places.

~ puzzle 3: where's the factor of 3? ~

Show the middle of any sandwich is never divisible by 3. The factor of 3 always lives in an outer slice.

~ show solution ~ ~ hide solution ~

Suppose the middle is divisible by 3. It’s also even (Puzzle 1), so it’s divisible by both 2 and 3, hence by 6. Middle is 6m6m for some mm.

But the middle is a distinct semiprime: exactly two different primes. We see 2 and 3 both dividing it, so those are its two primes. No room for anything else. Middle has to be 23=62 \cdot 3 = 6.

If the middle is 6, the sandwich is (5,6,7)(5, 6, 7). 5 and 7 are primes, not semiprimes. So no sandwich has middle 6, and no sandwich has middle divisible by 3.

Now use “exactly one of three consecutive integers is divisible by 3.” The middle isn’t, so the factor of 3 has to be in the bottom or the top.

This is the seed of the Class A / Class B classification (more in §2).

~ puzzle 4: make 'no four in a row' tight ~

We argued the max chain length is 3 above. Make the argument maximally tight: for any nn, prove that at least one of {n,n+1,n+2,n+3}\{n, n+1, n+2, n+3\} fails to be a distinct semiprime, without splitting into “n is odd” / “n is even” cases. (Hint: just look at which integer is divisible by 4 directly.)

~ show solution ~ ~ hide solution ~

Among any four consecutive integers, exactly one is divisible by 4 (residues mod 4 cycle through {0,1,2,3}\{0, 1, 2, 3\} once in any 4-window). Call it mm.

If mm is a distinct semiprime, then m=pqm = p \cdot q with pqp \neq q both prime. But 4m4 \mid m means 2 appears in mm‘s factorization with multiplicity 2\geq 2, forcing p=q=2p = q = 2. That contradicts pqp \neq q.

So mm is not a distinct semiprime. The chain of four breaks at mm. Max sandwich length is 3. ∎

Bonus. The “wall” (the four-window’s slot that always breaks) is whichever integer is divisible by 4. So in any sandwich (n,n+1,n+2)(n, n+1, n+2), one of its immediate neighbors n1n - 1 or n+3n + 3 is divisible by 4. That’s the wall blocking extension. Useful for Puzzle 5.

~ puzzle 5: do twin sandwiches exist? ~

Twin sandwich: (n,n+1,n+2)(n, n+1, n+2) and (n+4,n+5,n+6)(n+4, n+5, n+6) both sandwiches, with just the single integer n+3n+3 as a wall between them. Six distinct semiprimes packed into seven consecutive integers. Real or fake? Find one or argue they can’t exist.

~ show solution ~ ~ hide solution ~

They exist, but rare. Smallest is at (213,214,215)(213, 214, 215) and (217,218,219)(217, 218, 219):

213=371,214=2107,215=543217=731,218=2109,219=373\begin{aligned} 213 &= 3 \cdot 71, & 214 &= 2 \cdot 107, & 215 &= 5 \cdot 43 \quad \checkmark \\ 217 &= 7 \cdot 31, & 218 &= 2 \cdot 109, & 219 &= 3 \cdot 73 \quad \checkmark \end{aligned}

Wall: 216=2333216 = 2^3 \cdot 3^3. That’s the wall from Puzzle 4 (the one in the 4-window divisible by 4).

Neat fact: 216=636216 = 6 \cdot 36, so 3621636 \mid 216. Not a coincidence: every twin-sandwich wall is divisible by 36. Quick sketch: both middles are 2pi2p_i for primes pip_i, so the wall n+3=2p1+2=2(p1+1)n + 3 = 2p_1 + 2 = 2(p_1 + 1) inherits a factor of 4 (since p1p_1 is odd, p1+1p_1 + 1 is even). A class-structure argument from §2 forces another factor of 9. Multiply: 36.

The twin sandwich question is also way harder than it looks. In §2 I’ll show that proving infinitely many twin sandwiches exist would imply the twin prime conjecture, open since 1849. So while twin sandwiches do exist, proving they keep happening is at least as hard as one of the famous open problems in number theory.

The factor-of-three split

Class A and Class B

Where does the factor of 3 live in a sandwich? Let me check the first three:

(33,34,35)=(311, 217, 57)(85,86,87)=(517, 243, 329)(93,94,95)=(331, 247, 519)\begin{aligned} (33, 34, 35) &= (3 \cdot 11,\ 2 \cdot 17,\ 5 \cdot 7) \\ (85, 86, 87) &= (5 \cdot 17,\ 2 \cdot 43,\ 3 \cdot 29) \\ (93, 94, 95) &= (3 \cdot 31,\ 2 \cdot 47,\ 5 \cdot 19) \end{aligned}

In (33,34,35)(33, 34, 35) it’s the bottom. In (85,86,87)(85, 86, 87) it’s the top. In (93,94,95)(93, 94, 95) back in the bottom. The factor of 3 jumps around between the two outer slices.

Why never the middle? We showed in Puzzle 3 of §1: the middle of any sandwich is never divisible by 3. So the factor of 3 has exactly two places it can live: the bottom or the top. That gives us the binary classification this section is about.

A semiprime sandwich is Class A if 3 divides the bottom slice, and Class B if 3 divides the top slice. Every sandwich is exactly one of these. Going by the table above: (33,34,35)(33, 34, 35) is Class A, (85,86,87)(85, 86, 87) is Class B, (93,94,95)(93, 94, 95) is Class A.

the linear couplings

Each class has a clean algebraic shape. The middle is always 2p2p for pp an odd prime (Puzzle 1 of §1). The factor-of-3 slice is 3b3b for bb an odd prime 3\neq 3. Lining the two facts up:

Classbottommiddletop
A3b3b2p2p3b+23b + 2
B3b23b - 22p2p3b3b

Class A: the middle is exactly one more than the bottom, giving 2p=3b+12p = 3b + 1. Class B: the middle is exactly one less than the top, giving 3b=2p+13b = 2p + 1.

These are the linear couplings. They tie the two auxiliary primes (pp in the middle, bb in the factor-of-3 slice) together with one easy equation each. Pretty much every modular constraint we’ll see falls out by reducing one of these mod something small.

~ puzzle 1: check the couplings ~

Identify pp and bb for each of the first three sandwiches, name the class, and verify the linear coupling for that class.

~ show solution ~ ~ hide solution ~
sandwichppbbclasscheck
(33, 34, 35)1711A2p=342p = 34, 3b+1=343b + 1 = 34
(85, 86, 87)4329B3b=873b = 87, 2p+1=872p + 1 = 87
(93, 94, 95)4731A2p=942p = 94, 3b+1=943b + 1 = 94

detect the class from p alone

Small but useful observation. If you know just the middle prime pp, you can decide the class by looking at p(mod3)p \pmod 3.

~ puzzle 2: class from p mod 3 ~

Show that a sandwich is Class A iff p2(mod3)p \equiv 2 \pmod 3, and Class B iff p1(mod3)p \equiv 1 \pmod 3.

~ show solution ~ ~ hide solution ~

Reduce each linear coupling mod 3.

Class A. 2p=3b+12p = 3b + 1. The right side is 0+11(mod3)0 + 1 \equiv 1 \pmod 3, so 2p1(mod3)2p \equiv 1 \pmod 3. The inverse of 2 mod 3 is itself (221(mod3)2 \cdot 2 \equiv 1 \pmod 3), so p2(mod3)p \equiv 2 \pmod 3.

Class B. 3b=2p+13b = 2p + 1. The left side is 0(mod3)0 \pmod 3, so 2p+10(mod3)2p + 1 \equiv 0 \pmod 3, i.e. 2p12(mod3)2p \equiv -1 \equiv 2 \pmod 3, giving p1(mod3)p \equiv 1 \pmod 3.

Spot check. (33,34,35)(33, 34, 35): p=172(mod3)p = 17 \equiv 2 \pmod 3, so Class A ✓. (85,86,87)(85, 86, 87): p=431(mod3)p = 43 \equiv 1 \pmod 3, so Class B ✓.

square sandwiches are always Class B

A square sandwich is one whose bottom slice is the square of a prime: (r2,r2+1,r2+2)(r^2, r^2 + 1, r^2 + 2) for rr prime. The motivating example (121,122,123)(121, 122, 123) is one. Most of the rest of this pamphlet is about square sandwiches specifically.

Quick fact about them: every square sandwich is Class B.

If it were Class A, then 3 would divide the bottom r2r^2, which means 3 divides rr (since 3 is prime). The only prime divisible by 3 is 3 itself, giving the triple (9,10,11)(9, 10, 11). But 11 is prime, not a semiprime. So no Class A square sandwich exists.

Square sandwiches are always Team Class B.

you can’t pack two sandwiches back-to-back

How tightly can two sandwiches sit? Could you have (n,n+1,n+2)(n, n+1, n+2) and (n+3,n+4,n+5)(n+3, n+4, n+5)? Six distinct semiprimes in a row?

No. The middles would be n+1n+1 and n+4n+4, both even (Puzzle 1 of §1). But they differ by 3, which is odd. Two evens can’t differ by an odd number. Contradiction.

So sandwiches always have at least one non-semiprime integer between them. The tightest possible configuration is the twin sandwich: (n,n+1,n+2)(n, n+1, n+2) and (n+4,n+5,n+6)(n+4, n+5, n+6), separated by the lone integer n+3n+3. Six distinct semiprimes among seven consecutive integers.

We met the smallest twin sandwich in Puzzle 5 of §1: (213,214,215)(213, 214, 215) and (217,218,219)(217, 218, 219), with separator 216=2333216 = 2^3 \cdot 3^3.

~ puzzle 3: the twin sandwich gap is divisible by 4 ~

Show that if (n,n+1,n+2)(n, n+1, n+2) and (n+4,n+5,n+6)(n+4, n+5, n+6) are both sandwiches, then the separator n+3n+3 is divisible by 4.

~ show solution ~ ~ hide solution ~

The two middles are n+1=2p1n+1 = 2p_1 and n+5=2p2n+5 = 2p_2 for primes p1,p2p_1, p_2 (both odd, since both >2> 2).

The separator is n+3=(n+1)+2=2p1+2=2(p1+1)n+3 = (n+1) + 2 = 2p_1 + 2 = 2(p_1 + 1). Since p1p_1 is odd, p1+1p_1 + 1 is even, so 2(p1+1)2(p_1 + 1) is divisible by 22=42 \cdot 2 = 4. ✓

A more careful argument using the class structure of both sandwiches actually shows 36(n+3)36 \mid (n + 3). Schoenfield observed this on OEIS sequence A202319. We’ll skip the mod-9 piece. The takeaway: twin sandwiches are very rare and pinned to a sparse residue class.

twin sandwiches are at least as hard as twin primes

Punchline of this section. Proving twin sandwich infinitude is at least as hard as the famous twin prime conjecture (open since 1849).

Suppose (n,n+1,n+2)(n, n+1, n+2) and (n+4,n+5,n+6)(n+4, n+5, n+6) are both sandwiches. Each carries a factor of 3 in one of its outer slices (Class A or Class B). The two factor-of-3 slices land at one of these distances apart on the integer line:

sandwich 1sandwich 2factor-of-3 distance
Class A (3 in bottom nn)Class A (3 in bottom n+4n+4)4
Class A (3 in bottom nn)Class B (3 in top n+6n+6)6
Class B (3 in top n+2n+2)Class A (3 in bottom n+4n+4)2
Class B (3 in top n+2n+2)Class B (3 in top n+6n+6)4

The two factor-of-3 slices look like 3b13b_1 and 3b23b_2 with b1,b2b_1, b_2 primes. So 3(b2b1)3(b_2 - b_1) has to be one of {2,4,6}\{2, 4, 6\}. Only 3(b2b1)=63(b_2 - b_1) = 6 has an integer solution, giving b2b1=2b_2 - b_1 = 2.

So the two bb-primes form a twin prime pair. An infinite family of twin sandwiches gives you an infinite family of twin primes for free.

The twin prime conjecture is open. So twin sandwich infinitude is open in a strictly harder way.

~ puzzle 4: same-class twins don't work ~

Above I claimed only the (Class A, Class B) pairing at distance 6 works (with b2b1=2b_2 - b_1 = 2). Argue this directly: show that if both sandwiches are the same class (both A or both B), the resulting equation has no integer solution.

~ show solution ~ ~ hide solution ~

Two Class A: factors of 3 sit at the bottoms nn and n+4n+4, distance 4. So 3b23b1=43b_2 - 3b_1 = 4, i.e. 3(b2b1)=43(b_2 - b_1) = 4. No integer b2b1b_2 - b_1 makes 3k=43 \cdot k = 4. ✗

Two Class B: factors of 3 sit at the tops n+2n+2 and n+6n+6, distance 4. Same equation 3(b2b1)=43(b_2 - b_1) = 4. No integer solution. ✗

So twin sandwiches must mix classes. From the table, both mixed pairings give b2b1=±2b_2 - b_1 = \pm 2, i.e. the two bb-primes are twin primes.

but square sandwiches don’t twin

Surprise: square sandwiches never appear in twin configuration. Empirically, zero clusters across all 4,668 square sandwiches with r<107r < 10^7.

~ puzzle 5: square sandwiches are isolated ~

Show that if (r2,r2+1,r2+2)(r^2, r^2 + 1, r^2 + 2) is a square sandwich with r>5r > 5 prime, then (r2+4,r2+5,r2+6)(r^2 + 4, r^2 + 5, r^2 + 6) is not a sandwich.

~ show solution ~ ~ hide solution ~

The starting square sandwich is Class B (we proved this above), so 3r2+23 \mid r^2 + 2, which gives r21(mod3)r^2 \equiv 1 \pmod 3.

Look at the candidate next triple (r2+4,r2+5,r2+6)(r^2 + 4, r^2 + 5, r^2 + 6) mod 3:

  • r2+41+12(mod3)r^2 + 4 \equiv 1 + 1 \equiv 2 \pmod 3
  • r2+51+20(mod3)r^2 + 5 \equiv 1 + 2 \equiv 0 \pmod 3
  • r2+61+01(mod3)r^2 + 6 \equiv 1 + 0 \equiv 1 \pmod 3

The middle of this candidate is divisible by 3. But the middle of any sandwich is never divisible by 3 (Puzzle 3 of §1). So the candidate isn’t a sandwich. ✓

Square sandwiches are isolated. They never appear in twin configuration.

Sandwich anatomy

The square-centered case

For the rest of this pamphlet I’ll narrow focus to square sandwiches: sandwiches whose bottom slice is the square of a prime. Like (121,122,123)(121, 122, 123) where 121=112121 = 11^2.

Two facts about square sandwiches we already have:

  1. The bottom is r2=rrr^2 = r \cdot r, a non-distinct semiprime. (That’s OK. The original “distinct” condition is really about the middle and top, and we’ll keep enforcing it there.)
  2. The sandwich is Class B (we proved this in §2). The factor of 3 lives in the top.

So for any prime rr, the candidate sandwich looks like

(r2, r2+1, r2+2)(r^2,\ r^2 + 1,\ r^2 + 2)

with r2+1=2pr^2 + 1 = 2p (pp prime, since the middle is 2p2p from Puzzle 1 of §1) and r2+2=3br^2 + 2 = 3b (bb prime, Class B). Solving:

p=r2+12,b=r2+23.p = \frac{r^2 + 1}{2}, \qquad b = \frac{r^2 + 2}{3}.

Subtract the equations: (r2+2)(r2+1)=3b2p(r^2 + 2) - (r^2 + 1) = 3b - 2p, giving 3b=2p+13b = 2p + 1. That’s the Class B linear coupling we already met in §2.

The whole sandwich is determined by rr. The sandwich exists iff rr, pp, and bb are all prime.

the smallest examples by hand

Let me walk through small primes rr and compute p,bp, b:

rrr2r^2ppbbsandwich?
39511/311/3 (not integer)
525139 (not prime)
74925 = 5² (not prime)17
111216141
1316985 = 5·17 (not prime)57 = 3·19 (not prime)
17289145 = 5·29 (not prime)97
19361181121 = 11² (not prime)
23529265 = 5·53 (not prime)177 = 3·59 (not prime)
29841421281

Sparse. Among rr up to 29, only 11 and 29 produce sandwiches. So 121 and 841 are the first two prime squares that center a sandwich.

modular constraints, slowly

Some patterns are visible in the table. Several rr values fail in similar ways. Which rr can possibly produce a sandwich at all?

The trick is to take each defining equation and reduce it modulo a small prime. Three reductions are enough to pin down the picture: mod 3, mod 4, mod 5.

mod 4

rr is an odd prime, so r1r \equiv 1 or 3(mod4)3 \pmod 4. In either case r21(mod8)r^2 \equiv 1 \pmod 8 (just check r=1,3,5,7r = 1, 3, 5, 7: their squares are 1,9,25,491, 9, 25, 49, all 1(mod8)\equiv 1 \pmod 8).

So r2+12(mod8)r^2 + 1 \equiv 2 \pmod 8, which means p=(r2+1)/21(mod4)p = (r^2 + 1)/2 \equiv 1 \pmod 4.

The middle prime pp is always one more than a multiple of 4.

mod 3

rr is prime and r3r \neq 3, so r1r \equiv 1 or 2(mod3)2 \pmod 3. Squaring kills the sign: r21(mod3)r^2 \equiv 1 \pmod 3.

So r2+12(mod3)r^2 + 1 \equiv 2 \pmod 3, and p=(r2+1)/2p = (r^2 + 1)/2. To divide by 2 mod 3, multiply by 2’s inverse, which is 2 (since 221(mod3)2 \cdot 2 \equiv 1 \pmod 3). So p41(mod3)p \equiv 4 \equiv 1 \pmod 3.

This also matches what §2 said: square sandwiches are Class B, and Class B forces p1(mod3)p \equiv 1 \pmod 3.

mod 5

rr is prime and r5r \neq 5, so r1,2,3,r \equiv 1, 2, 3, or 4(mod5)4 \pmod 5. Squaring: r2{1,4}(mod5)r^2 \in \{1, 4\} \pmod 5.

If r24(mod5)r^2 \equiv 4 \pmod 5, then r2+10(mod5)r^2 + 1 \equiv 0 \pmod 5, which means 52p5 \mid 2p, so 5p5 \mid p. But pp is prime >5> 5, contradiction. So r21(mod5)r^2 \equiv 1 \pmod 5.

Then r2+12(mod5)r^2 + 1 \equiv 2 \pmod 5. Inverse of 2 mod 5 is 3 (since 23=61(mod5)2 \cdot 3 = 6 \equiv 1 \pmod 5). So p61(mod5)p \equiv 6 \equiv 1 \pmod 5.

gluing them together

We’ve shown p1(mod4)p \equiv 1 \pmod 4, p1(mod3)p \equiv 1 \pmod 3, p1(mod5)p \equiv 1 \pmod 5. The Chinese Remainder Theorem (CRT) says: residue conditions modulo coprime numbers can be glued. If m1,m2,m3m_1, m_2, m_3 are pairwise coprime, knowing aa mod each pins down aa mod m1m2m3m_1 m_2 m_3.

Here 3, 4, 5 are pairwise coprime, with product 60. Each condition is "p1p \equiv 1", which glues to:

~ result on p ~p1(mod60).p \equiv 1 \pmod{60}.

Every middle prime pp in a square sandwich is one more than a multiple of 60. Spot check: p=61,421,3121,36721,p = 61, 421, 3121, 36721, \ldots. All 1(mod60)\equiv 1 \pmod{60}. ✓

~ puzzle 1: verify p mod 60 on the small examples ~

Verify p1(mod60)p \equiv 1 \pmod{60} for r=11,29,79r = 11, 29, 79.

~ show solution ~ ~ hide solution ~

r=11r = 11: p=61=60+11(mod60)p = 61 = 60 + 1 \equiv 1 \pmod{60}. ✓

r=29r = 29: p=421=760+11(mod60)p = 421 = 7 \cdot 60 + 1 \equiv 1 \pmod{60}. ✓

r=79r = 79: p=3121=5260+11(mod60)p = 3121 = 52 \cdot 60 + 1 \equiv 1 \pmod{60}. ✓

the four lanes mod 30

The mod-5 step pinned r21(mod5)r^2 \equiv 1 \pmod 5, which means r1r \equiv 1 or 4(mod5)4 \pmod 5. Combine with the obvious ”rr is prime >5> 5” (so rr coprime to 2, 3, 5), and we can read off all surviving residues modulo 30=23530 = 2 \cdot 3 \cdot 5.

Primes >5> 5 live in residue classes coprime to 30, which are {1,7,11,13,17,19,23,29}(mod30)\{1, 7, 11, 13, 17, 19, 23, 29\} \pmod{30}. Eight classes. Demanding r1r \equiv 1 or 4(mod5)4 \pmod 5 kills four of them, leaving:

~ result on r ~r1, 11, 19, 29(mod30).r \equiv 1,\ 11,\ 19,\ 29 \pmod{30}.

Half of the eight prime-compatible residue classes mod 30 are eliminated by this one observation, before any computer search starts.

~ puzzle 2: kill four lanes by hand ~

Verify the lane restriction by checking, for each of r7,13,17,23(mod30)r \equiv 7, 13, 17, 23 \pmod{30}, that the middle slice r2+1r^2 + 1 ends up divisible by 5 (which kills pp from being prime once r>5r > 5).

~ show solution ~ ~ hide solution ~

Reduce each rr residue mod 5:

  • r7(mod30)r \equiv 7 \pmod{30}: r2(mod5)r \equiv 2 \pmod 5.
  • r13(mod30)r \equiv 13 \pmod{30}: r3(mod5)r \equiv 3 \pmod 5.
  • r17(mod30)r \equiv 17 \pmod{30}: r2(mod5)r \equiv 2 \pmod 5.
  • r23(mod30)r \equiv 23 \pmod{30}: r3(mod5)r \equiv 3 \pmod 5.

All four have r±2(mod5)r \equiv \pm 2 \pmod 5, so r24(mod5)r^2 \equiv 4 \pmod 5, so r2+10(mod5)r^2 + 1 \equiv 0 \pmod 5. That means 52p5 \mid 2p, so 5p5 \mid p. But p>5p > 5 has to be prime. Contradiction. ✓

the constraint on b

A similar analysis on bb (using r2+2=3br^2 + 2 = 3b, which rearranges to r22(modb)r^2 \equiv -2 \pmod b) gives:

b1 or 17(mod24).b \equiv 1 \text{ or } 17 \pmod{24}.

The key ingredient is that 2-2 has to be a quadratic residue modulo bb: there has to be some integer rr with r22(modb)r^2 \equiv -2 \pmod b. By the supplementary laws of quadratic reciprocity (don’t worry, you don’t need to know the proof to use the result), this happens iff b1b \equiv 1 or 3(mod8)3 \pmod 8. Combined with the mod-3 piece (Class B forces b≢0(mod3)b \not\equiv 0 \pmod 3), the answer mod 24 is exactly {1,17}\{1, 17\}.

We’ll come back to this in §6 with a much cleaner explanation in the language of the ring Z[2]\mathbb{Z}[\sqrt{-2}].

the brute force says

Searching primes r<10,000r < 10{,}000 in the four valid lanes turns up 35 sandwiches. The split between b1b \equiv 1 and b17(mod24)b \equiv 17 \pmod{24} runs 18 to 17. Nearly even. About 5.7% of primes in valid lanes actually produce a sandwich. Sparse but not vanishingly so.

The two clean small examples again:

  • r=11r = 11: p=61p = 61, b=41b = 41. Triple (121,122,123)(121, 122, 123).
  • r=29r = 29: p=421p = 421, b=281b = 281. Triple (841,842,843)(841, 842, 843).
~ puzzle 3: verify the next valid r by hand ~

The next valid rr after 29 is 79. Compute pp, bb, and check that all three are prime.

~ show solution ~ ~ hide solution ~

r2=6241r^2 = 6241.

p=(6241+1)/2=3121p = (6241 + 1)/2 = 3121. To check pp prime, divide by primes up to 312155.86\sqrt{3121} \approx 55.86: {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}\{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53\}. None divide 3121. So p=3121p = 3121 is prime. ✓

b=(6241+2)/3=2081b = (6241 + 2)/3 = 2081. Divide by primes up to 208145.6\sqrt{2081} \approx 45.6: same list up through 43. None divide 2081. So b=2081b = 2081 is prime. ✓

Lane check on rr: 79=230+1979 = 2 \cdot 30 + 19, so r19(mod30)r \equiv 19 \pmod{30}. One of the four valid lanes. ✓

Mod-60 check on pp: 3121=5260+13121 = 52 \cdot 60 + 1, so p1(mod60)p \equiv 1 \pmod{60}. ✓

Mod-24 check on bb: 2081=8624+172081 = 86 \cdot 24 + 17, so b17(mod24)b \equiv 17 \pmod{24}. ✓

The triple is (6241,6242,6243)=(792, 23121, 32081)(6241, 6242, 6243) = (79^2,\ 2 \cdot 3121,\ 3 \cdot 2081).

~ puzzle 4: check b mod 24 on the small examples ~

Verify b{1,17}(mod24)b \in \{1, 17\} \pmod{24} for r=11,29,79r = 11, 29, 79. Which lane does each fall into?

~ show solution ~ ~ hide solution ~

r=11r = 11: b=41=24+1717(mod24)b = 41 = 24 + 17 \equiv 17 \pmod{24}. (Lane 17.)

r=29r = 29: b=281=1124+1717(mod24)b = 281 = 11 \cdot 24 + 17 \equiv 17 \pmod{24}. (Lane 17.)

r=79r = 79: b=2081=8624+1717(mod24)b = 2081 = 86 \cdot 24 + 17 \equiv 17 \pmod{24}. (Lane 17.)

All three of the smallest valid rr values land in Lane 17. The first rr with b1(mod24)b \equiv 1 \pmod{24} is r=271r = 271, where b=24481=102024+1b = 24481 = 1020 \cdot 24 + 1. So Lane 1 takes a while to show up.

~ puzzle 5: when does a Pell solution kill the middle? ~

Try r=7r = 7. From the table above, p=25=52p = 25 = 5^2, not prime. Show that r=7r = 7 is special: it solves the negative Pell equation r22m2=1r^2 - 2m^2 = -1 for some integer mm. Find mm, and explain why any solution to the negative Pell equation forces pp to be a perfect square (so not prime, except trivially).

~ show solution ~ ~ hide solution ~

Try m=5m = 5: r22m2=4950=1r^2 - 2m^2 = 49 - 50 = -1. ✓

So r2+1=2m2r^2 + 1 = 2m^2, which means p=(r2+1)/2=m2p = (r^2 + 1)/2 = m^2. The middle “prime” is a perfect square. The only prime perfect square would be… well, there are none. (A prime has no nontrivial divisors, but m2=mmm^2 = m \cdot m has mm as a divisor for m>1m > 1.)

So every rr that solves r22m2=1r^2 - 2m^2 = -1 automatically fails the sandwich condition at the middle. The negative Pell equation has infinitely many solutions: r{1,7,41,239,1393,}r \in \{1, 7, 41, 239, 1393, \ldots\}. Free list of rr values that can never produce a sandwich. More on this in §6.

Why this is pretty

The Gaussian reframe

This is the part that surprised me. To say what’s going on we need a quick detour through the Gaussian integers.

a number system one step beyond ℤ

The Gaussian integers, written Z[i]\mathbb{Z}[i], are the complex numbers of the form

a+bi,a,bZ,a + bi, \qquad a, b \in \mathbb{Z},

where ii is the imaginary unit (i2=1i^2 = -1). You can add and multiply Gaussian integers using the usual rules, treating ii as a formal symbol that squares to 1-1. Examples:

(2+3i)+(1i)=3+2i,(2+3i)(1+i)=2+2i+3i+3i2=1+5i.(2 + 3i) + (1 - i) = 3 + 2i, \qquad (2 + 3i)(1 + i) = 2 + 2i + 3i + 3i^2 = -1 + 5i.

So Z[i]\mathbb{Z}[i] is a number system you can add, multiply, and (with care) factor in. Just like the ordinary integers, but in two dimensions instead of one. Geometrically: a lattice of points in the complex plane.

The role that “absolute value” plays for Z\mathbb{Z} is played here by the norm:

N(a+bi)=(a+bi)(abi)=a2+b2.N(a + bi) = (a + bi)(a - bi) = a^2 + b^2.

The norm is always a non-negative integer, and crucially it’s multiplicative:

N(αβ)=N(α)N(β).N(\alpha \beta) = N(\alpha) N(\beta).

So if αZ[i]\alpha \in \mathbb{Z}[i] factors as α=βγ\alpha = \beta \gamma, then N(α)=N(β)N(γ)N(\alpha) = N(\beta) N(\gamma). The norm factors too. That’s the lever for everything below: knowing how integer primes factor in Z[i]\mathbb{Z}[i] tells you about norms, and knowing about norms tells you about sums of squares.

Gaussian primes and Fermat’s two-squares theorem

A Gaussian prime is the analogue of an ordinary prime: a Gaussian integer π\pi that can’t be written as π=αβ\pi = \alpha \beta for non-trivial α,β\alpha, \beta (where “non-trivial” means not multiples of ±1\pm 1 or ±i\pm i, the four units in Z[i]\mathbb{Z}[i]).

The structure of Gaussian primes is governed by Fermat’s old theorem on sums of two squares.

~ Fermat’s two-squares theorem ~

An odd prime pp can be written as p=a2+b2p = a^2 + b^2 for some integers a,ba, b if and only if p1(mod4)p \equiv 1 \pmod 4.

In the language of Z[i]\mathbb{Z}[i]:

  • Primes p1(mod4)p \equiv 1 \pmod 4 split as p=ππˉp = \pi \bar\pi for a Gaussian prime π=a+bi\pi = a + bi of norm pp.
  • Primes p3(mod4)p \equiv 3 \pmod 4 stay prime in Z[i]\mathbb{Z}[i] (their norm is p2p^2).
  • The prime 2=(1+i)(1i)2 = (1 + i)(1 - i) is a special “ramified” case.

So whenever you spot a prime p1(mod4)p \equiv 1 \pmod 4, you also spot a Gaussian prime π\pi of norm pp sitting in the lattice. Now back to sandwiches.

the centered-square identity

Set r=2k+1r = 2k + 1 (every odd r>2r > 2 has this form, with k=(r1)/2k = (r - 1)/2), and look at the middle prime of the sandwich:

p=r2+12=(2k+1)2+12=4k2+4k+22=2k2+2k+1.p = \frac{r^2 + 1}{2} = \frac{(2k + 1)^2 + 1}{2} = \frac{4k^2 + 4k + 2}{2} = 2k^2 + 2k + 1.

Now watch this:

2k2+2k+1=k2+(k2+2k+1)=k2+(k+1)2.2k^2 + 2k + 1 = k^2 + (k^2 + 2k + 1) = k^2 + (k + 1)^2.

So the middle prime is always a sum of two consecutive squares.

~ key identity ~p=r2+12=k2+(k+1)2wherek=r12.p = \frac{r^2 + 1}{2} = k^2 + (k + 1)^2 \quad\text{where}\quad k = \frac{r - 1}{2}.

These primes (sums of two consecutive squares) are the centered square primes, OEIS A027862.

Spot check. r=11r = 11, so k=5k = 5, so p=52+62=25+36=61p = 5^2 + 6^2 = 25 + 36 = 61. ✓ r=29r = 29, so k=14k = 14, so p=142+152=196+225=421p = 14^2 + 15^2 = 196 + 225 = 421. ✓

the Gaussian integer π_k

Whenever pp is a sum of two squares, pp shows up as a norm in Z[i]\mathbb{Z}[i]. In our case:

N(k+(k+1)i)=k2+(k+1)2=p.N(k + (k + 1)i) = k^2 + (k + 1)^2 = p.

So we have a Gaussian integer

πk=k+(k+1)iZ[i]\pi_k = k + (k + 1)i \in \mathbb{Z}[i]

whose norm is the middle prime. And whenever pp is actually prime in Z\mathbb{Z}, the element πk\pi_k is a Gaussian prime. (Why p1(mod4)p \equiv 1 \pmod 4, which Fermat’s theorem requires: exactly one of k,k+1k, k+1 is even, so pp is even-square + odd-square 0+11(mod4)\equiv 0 + 1 \equiv 1 \pmod 4.)

Geometrically, πk\pi_k sits one step above the diagonal in the lattice. On the line y=x+1y = x + 1.

~ puzzle 1: Gaussian prime iff rational prime ~

Show that πk=k+(k+1)i\pi_k = k + (k+1)i is a Gaussian prime if and only if p=k2+(k+1)2p = k^2 + (k+1)^2 is a rational prime.

~ show solution ~ ~ hide solution ~

(⇐) If pp is a rational prime, then πk\pi_k is a Gaussian prime. We have p1(mod4)p \equiv 1 \pmod 4 (computed above). By Fermat’s two-squares theorem, pp splits in Z[i]\mathbb{Z}[i] as p=ππˉp = \pi \bar \pi where π\pi is a Gaussian prime of norm pp. Since N(πk)=pN(\pi_k) = p and the Gaussian primes of norm pp are exactly π\pi and πˉ\bar \pi up to units, πk\pi_k is one of these. Gaussian prime ✓.

(⇒) If πk\pi_k is a Gaussian prime, then pp is a rational prime. The norm of any Gaussian prime is either a rational prime or the square of a rational prime 3(mod4)\equiv 3 \pmod 4. We computed p1(mod4)p \equiv 1 \pmod 4, ruling out the latter. So pp is a rational prime.

the (1+i) reformulation

Here’s a small but beautiful identity. In Z[i]\mathbb{Z}[i]:

(1+i)πk=(1+i)(k+(k+1)i)=k+(k+1)i+ki+(k+1)i2=(k(k+1))+(k+(k+1))i=1+(2k+1)i.(1 + i)\pi_k = (1 + i)(k + (k+1)i) = k + (k+1)i + ki + (k+1)i^2 = (k - (k+1)) + (k + (k+1))i = -1 + (2k+1)i.

But 2k+1=r2k + 1 = r. So:

~ the (1+i) identity ~(1+i)πk=1+ri.(1 + i)\pi_k = -1 + ri.

The sandwich-generating prime rr shows up as the imaginary part of (1+i)πk(1+i)\pi_k, with real part identically 1-1. Multiplying by 1+i1 + i in Z[i]\mathbb{Z}[i] is a 45° rotation followed by a scaling by 2\sqrt 2, so this identity says: rotate πk\pi_k by 45° and scale up, and you land on the vertical line Re(z)=1\text{Re}(z) = -1 at height rr.

A one-parameter Gaussian-arithmetic encoding of the entire square-sandwich structure. Every valid rr corresponds to a Gaussian prime πk\pi_k such that (1+i)πk=1+ri(1 + i)\pi_k = -1 + ri, with r=2k+1r = 2k + 1.

the geometric picture

The argument (angle) of πk=k+(k+1)i\pi_k = k + (k+1)i is

arg(πk)=arctan ⁣(k+1k)arctan(1)=π4=45°as k.\arg(\pi_k) = \arctan\!\left(\frac{k+1}{k}\right) \to \arctan(1) = \frac{\pi}{4} = 45° \quad\text{as } k \to \infty.

So sandwich-generating Gaussian primes don’t appear randomly across the lattice. They spiral toward the diagonal y=xy = x as kk grows, hugging the line y=x+1y = x + 1 from above and landing closer and closer to a 45° angle.

rrkkπk\pi_karg(πk)\arg(\pi_k)
1155+6i5 + 6i50.19°50.19°
291414+15i14 + 15i46.97°46.97°
793939+40i39 + 40i45.73°45.73°
271135135+136i135 + 136i45.21°45.21°

Picture: an infinite sequence of dots on the line y=x+1y = x + 1, starting visibly above the diagonal and slowly settling onto it, picking out the centered-square primes as you go. The places where the dot isn’t a Gaussian prime (like π3=3+4i\pi_3 = 3 + 4i) are exactly where the would-be middle prime pp turns out to be composite.

why r = 7 fails, Gaussian-style

At r=7r = 7, we have k=3k = 3, so π3=3+4i\pi_3 = 3 + 4i. The norm is N(π3)=9+16=25=52N(\pi_3) = 9 + 16 = 25 = 5^2. By Puzzle 1 above, since 25=5225 = 5^2 isn’t a rational prime, π3\pi_3 isn’t a Gaussian prime either.

Concretely, π3\pi_3 factors as

π3=(2+i)2.\pi_3 = (2 + i)^2.

(Quick check: (2+i)2=4+4i+i2=4+4i1=3+4i(2 + i)^2 = 4 + 4i + i^2 = 4 + 4i - 1 = 3 + 4i. ✓) The factor (2+i)(2 + i) is itself a Gaussian prime (norm 55, prime), so π3\pi_3 is a Gaussian prime squared, not a Gaussian prime itself.

The would-be middle prime at r=7r = 7 is p=N(π3)=25p = N(\pi_3) = 25, which is composite. The Z[i]\mathbb{Z}[i] side and the Z\mathbb{Z} side fail in lockstep: π3\pi_3 doesn’t stay irreducible in Z[i]\mathbb{Z}[i], pp doesn’t stay prime in Z\mathbb{Z}. There’s a deeper reason this happens at r=7r = 7 specifically (it’s a solution to the negative Pell equation r22m2=1r^2 - 2m^2 = -1 with m=5m = 5). More on that in §6.

the small-k failures

The construction starts working at k=5k = 5 (giving r=11r = 11). For k<5k < 5, at least one of the three sandwich conditions fails.

~ puzzle 2: why does the list start at k=5? ~

For each of k=1,2,3,4k = 1, 2, 3, 4, identify which condition fails:

  • r=2k+1r = 2k + 1 prime,
  • p=(r2+1)/2p = (r^2 + 1)/2 prime,
  • b=(r2+2)/3b = (r^2 + 2)/3 prime.
~ show solution ~ ~ hide solution ~

k = 1, r = 3. Triple is (9,10,11)(9, 10, 11). We have r2+1=10=25r^2 + 1 = 10 = 2 \cdot 5 ✓. But r2+2=11r^2 + 2 = 11 is prime, not a semiprime. The factor of 3 isn’t in any slice (the bottom 9=329 = 3^2 has 3 but isn’t a distinct semiprime). Fails.

k = 2, r = 5. Triple is (25,26,27)(25, 26, 27). Middle 26=21326 = 2 \cdot 13 ✓. Top 27=3327 = 3^3 is not a distinct semiprime (b=9b = 9 is not prime). Fails.

k = 3, r = 7. Triple is (49,50,51)(49, 50, 51). Top 51=31751 = 3 \cdot 17 ✓. Middle 50=25250 = 2 \cdot 5^2, not a distinct semiprime (p=25p = 25 is not prime). This is the Pell failure: π3\pi_3 isn’t a Gaussian prime.

k = 4, r = 9. r=9=32r = 9 = 3^2 is not prime. Fails at step 1.

Smallest kk where all three conditions hold: k=5k = 5, giving r=11r = 11 and the motivating triple (121,122,123)(121, 122, 123).

The first ten valid kk values:

5
14
39
135
189
230
260
315
369
440

Corresponding middle primes: 61,421,3121,36721,71821,61, 421, 3121, 36721, 71821, \ldots. All centered square primes (forced by the construction).

~ puzzle 3: verify the (1+i) identity ~

Verify (1+i)πk=1+ri(1+i)\pi_k = -1 + ri for k=5k = 5 (so r=11r = 11, π5=5+6i\pi_5 = 5 + 6i).

~ show solution ~ ~ hide solution ~

Compute (1+i)(5+6i)(1 + i)(5 + 6i):

(1+i)(5+6i)=5+6i+5i+6i2=5+11i6=1+11i.(1 + i)(5 + 6i) = 5 + 6i + 5i + 6i^2 = 5 + 11i - 6 = -1 + 11i.

And r=11r = 11, so 1+11i=1+ri-1 + 11i = -1 + ri. ✓

~ puzzle 4: the diagonal interpretation ~

The points πk=k+(k+1)i\pi_k = k + (k+1)i all lie on the line y=x+1y = x + 1 in the Gaussian lattice. Show that the next parallel line y=x+2y = x + 2 contains no Gaussian primes at all.

~ show solution ~ ~ hide solution ~

For α=a+(a+2)i\alpha = a + (a + 2)i, the norm is

N(α)=a2+(a+2)2=2a2+4a+4=2(a2+2a+2)=2((a+1)2+1).N(\alpha) = a^2 + (a + 2)^2 = 2a^2 + 4a + 4 = 2(a^2 + 2a + 2) = 2((a + 1)^2 + 1).

Always even, and 2\geq 2, with equality only at a=1a = -1 (giving α=1+i\alpha = -1 + i, a unit times 1+i1 + i).

For a1a \neq -1, N(α)N(\alpha) is even and >2> 2, so N(α)=2mN(\alpha) = 2 \cdot m for some m>1m > 1. By multiplicativity of the norm, α\alpha has to factor non-trivially. So α\alpha isn’t a Gaussian prime.

The line y=x+1y = x + 1 is the unique slope-1 line in the lattice along which Gaussian primes appear infinitely often. The line y=x+2y = x + 2 has the parity baked in, killing every candidate.

~ puzzle 5: factor π_3 explicitly ~

Above I claimed π3=3+4i=(2+i)2\pi_3 = 3 + 4i = (2 + i)^2. Verify by direct computation. Then check that (2+i)(2 + i) is a Gaussian prime, and explain why π3\pi_3 being a square of a Gaussian prime (rather than a Gaussian prime itself) is exactly what makes p=N(π3)=25p = N(\pi_3) = 25 composite.

~ show solution ~ ~ hide solution ~

Direct computation. (2+i)2=4+4i+i2=4+4i1=3+4i=π3(2 + i)^2 = 4 + 4i + i^2 = 4 + 4i - 1 = 3 + 4i = \pi_3. ✓

(2+i)(2 + i) is a Gaussian prime. Its norm is N(2+i)=4+1=5N(2 + i) = 4 + 1 = 5, which is a rational prime. The norm of a Gaussian prime is either a rational prime or the square of a rational prime 3(mod4)\equiv 3 \pmod 4. The norm 5 is a rational prime, so (2+i)(2 + i) is a Gaussian prime.

Why p=25p = 25 is composite. p=N(π3)=N((2+i)2)=N(2+i)2=52=25p = N(\pi_3) = N((2 + i)^2) = N(2 + i)^2 = 5^2 = 25. So pp is the square of a rational prime, hence composite.

The structural pattern: πk\pi_k being a Gaussian prime ⟺ p=N(πk)p = N(\pi_k) being a rational prime. When πk\pi_k factors in Z[i]\mathbb{Z}[i], pp factors in Z\mathbb{Z}. The two factorizations are linked.