Spock’s π Gambit
“Wolf in the Fold” — Star Trek: The Original Series (1967)
An ancient evil takes over the Enterprise computer. Spock’s counter: compute π to its last digit.
There is no last digit.
“Wolf in the Fold” — Season 2, Episode 14 — December 22, 1967
Written by Robert Bloch — the same author who wrote Psycho — and directed by Joseph Pevney, “Wolf in the Fold” is one of the original series’ most deliberately gothic episodes. Bloch transplanted the Jack the Ripper mythology wholesale into the 23rd century, then added a science-fiction layer that makes the horror genuinely cosmic.
The Enterprise is visiting Argelius II, a pleasure planet so gentle and hedonistic that it has no crime. Mr. Scott (“Scotty”) is there for therapeutic shore leave, recovering from an injury caused by a woman during a shipboard accident; Dr. McCoy has recommended the visit to improve his fraught feelings. A dancer named Kara leaves with Scotty. Moments later, Kirk and McCoy find her stabbed to death with Scotty standing over her, bloody knife in hand, with no memory of what happened.
Two more murders follow in quick succession. The prefect’s wife, Sybo, conducts an empathic-contact ritual to find the truth. In trance, she speaks of “a monstrous, terrible evil” — “a hunger that never dies” — and names it: Kesla. Beratis. Redjac. Then the lights go out and she is killed. Scotty is again found holding her body.
Aboard the Enterprise, the computer identifies the pattern. Redjac is an ancient non-corporeal entity that has traveled the galaxy for centuries, feeding on human fear. It inhabited Jack the Ripper in Whitechapel in 1888. It was known as Kesla on Deneb II and Beratis on Rigel IV. It possesses a humanoid body to commit acts of mass terror, harvesting the resulting fear as sustenance. The name “Redjac” is a transliteration: Red + Jack = the Ripper.
The entity is revealed to be inhabiting Mr. Hengist, the Rigellian administrator. When confronted, Redjac abandons Hengist’s body and jumps directly into the Enterprise’s computer systems. From there it can control the entire ship — life support, weapons, internal communications — and it begins broadcasting threats and horror to generate the terror it feeds on.
The counter-strategy is two-pronged. Dr. McCoy drugs the entire crew with fast-acting tranquilizers — a terrified crew is dangerous cargo, but a tranquilized one deprives Redjac of its food source. And Spock, with elegant mathematical precision, delivers the killing stroke:
The entity, now merged with the computer, cannot stop calculating. It is trapped in an infinite loop. Redjac eventually re-enters Hengist’s now-tranquilized body, and Kirk beams the body into space at maximum dispersal — scattering the entity’s particles across the void, where it perishes. The crew, still sedated, is sent back to Argelius to resume shore leave. “It might take up knitting,” McCoy observes about the tranquilized Redjac, “but nothing more harmful than that.”
Why π has no last digit — the math Spock knew
The brilliance of Spock’s move is not that the calculation is hard. It is that the calculation is mathematically impossible to complete. Not difficult — impossible. And a computer given an impossible task will not pause and reflect; it will simply keep computing forever.
π (pi) is an irrational number. This means it cannot be expressed as the ratio of two integers (p/q). Irrational numbers have decimal expansions that are infinite and non-repeating. There is no pattern; the digits simply continue without end:
π is further classified as a transcendental number — proven by Carl Louis Ferdinand von Lindemann in 1882. Transcendental numbers cannot be the root of any polynomial equation with integer coefficients. They are, in a precise mathematical sense, “more irrational” than algebraic irrationals like √2. The proof of π’s transcendence also settled the ancient problem of “squaring the circle” — proving once and for all that it is impossible to construct a square with the same area as a given circle using only a compass and straightedge.
Because π has no last digit, any system tasked with finding that digit will run forever. Not for a very long time. Forever. The computer cannot report “task complete” because the completion condition does not exist. It has been handed a problem with no solution — and it has no way of knowing that, because the task appears structurally valid: “compute this number to N decimal places” is a standard type of instruction.
This is a subtle but important distinction: Spock did not ask the computer to do something it would take a trillion years to finish. He asked it to do something that would take infinite time. Those are categorically different. A trillion-year task would eventually complete. A task requiring infinite steps never does.
In modern computing, calculating π to many decimal places is used as a benchmark for processor speed, memory bandwidth, and floating-point precision. As of 2024, π has been computed to over 100 trillion digits — a record that required weeks of computation on specialized hardware. None of those 100 trillion digits is the last one. None ever will be.
The Halting Problem echo. In 1936, Alan Turing proved that there is no general algorithm that can determine, for an arbitrary program and input, whether the program will ever finish running. Spock’s gambit is an elegant practical instance of this: he has given the computer a program that will never halt. The computer cannot determine this — it just keeps running.
Why this belongs in the CS and mathematics classroom
Most students encounter π as a number they memorize to a few decimal places for geometry formulas. This scene reframes it completely: π is not a number you compute — it is a number whose computation has no end. That single reframe opens several important doors.
Discussion prompts for the CS and math classroom:
- Rational vs. irrational numbers. What does it mean for a number to be irrational? Can you represent √2 exactly in a computer? How does floating-point representation deal with numbers that cannot be stored precisely?
- Infinite loops vs. very long loops. Is there a practical difference between a program that runs for a trillion years and one that runs forever? (Answer: yes — the trillion-year program terminates. The infinite one never does, even in principle.)
- The Halting Problem. Spock’s move is an application of the mathematical fact that some computations do not halt. Turing’s 1936 paper proved this rigorously. What are the implications for programs that call other programs?
- Pi as a benchmark. Modern programs that calculate π to millions of digits are used to test hardware and software. What algorithms are used? (Machin’s formula, the Bailey-Borwein-Plouffe formula, the Chudnovsky algorithm.) Why is this a better benchmark than, say, sorting a list?
- The science fiction angle. Spock needed to know, instantly and under pressure, a mathematical fact (that π has no last digit) and its computational implication (that any system tasked with finding it will never finish). That is applied mathematics under fire. How often does that happen in real engineering?
Compute π — Interactive App • Series Tutorial
Movie clips are only available in larger viewports.
On some mobile devices, rotating to landscape will allow viewing.
Spock’s π Gambit — “Wolf in the Fold”, 1967
The scene where Spock traps Redjac in the Enterprise computer by ordering it to compute π to its last decimal place. Watch for the moment the computer acknowledges the command and begins — and cannot stop.