Three years ago Christopher Havens, who has been serving a prison sentence of more than two decades for murder, published a discovery in number theory from his cell. A significant class of fractions, he and three co-authors showed, often maintains a regular structure after being transformed algebraically. Havens’s achievement was singular in another respect: he did not have access to computers, which mathematicians commonly program to tackle aspects of such calculations, so he painstakingly pieced his research together by hand.

Now a nonprofit co-founded by Havens has invented a computational programming platform built around one of the few technologies that people in prison do have access to: highly restricted, text-only e-mail. And as this facility begins to offer new opportunities, more and more incarcerated people are working on advanced mathematics to give meaning to their years behind bars.

Havens, who dropped out of high school as a sophomore, started studying mathematics in solitary confinement. “It brings out the worst in a lot of people,” he says. “Right above you, you got this fluorescent light that never shuts off, not even to go to sleep. You got these guys screaming. There [are] these guys that’ll stay up and just kick the wall.” To escape the indistinguishable days and nights, Havens began solving** **math puzzles: first Sudoku and then packets of algebra problems that a prison employee slipped under the door of his cell. “I would get lost in it for days and days and days,” he says. “I would dream about it.” By the end of his months in “the hole,” as people in prison call solitary confinement, Havens says, he was “knee-deep” in calculus and dipping his toes into the field he would ultimately publish in: number theory, the study of integers and the relationships among them.

But even out of solitary, teaching yourself mathematics in prison means getting stuck—not just on a problem but also on where to look for the solution. “Imagine you don’t have a professor or anything,” says James Conway III, who is studying measure theory—an extension of intuitive ideas about length, area and volume—from Ohio’s death row. “You’re on your own.” So after being released from the hole, Havens wrote to a journal published by Princeton University and the Institute for Advanced Study in Princeton, N.J., asking for a mathematician to correspond with. A few months later a group of researchers wrote back from Turin, Italy, first with guidance and eventually, as Havens’s years of mathematical exploration advanced him to the verge of discovery, with the question behind his first paper: How is a continued fraction *f* transformed by the operation (*af* + *b*) / (*cf* + *d*)?

Continued fractions look like mathematical *matryoshka* dolls, with one nested inside another, which is inside another, and so on, in a series. In this case, each doll is an integer added to a fraction whose denominator is the next smallest figurine in the sequence. While a “universal” solution to the transformation question the Turin researchers sent Havens has yet to be discovered, Havens found formulas for a specific class of transformations in the patterns of continued fractions he calculated by hand. These long chains of fractions could stretch out across 15 feet of notebook pages wallpapering his cell. It “took over two years to actually do the math,” Havens says.

For incarcerated people, days of tackling 21st-century problems with a pen and paper, however, may be coming to an end. Havens co-founded a national nonprofit, the Prison Mathematics Project (PMP), to help other people in prison overcome the challenges of studying mathematics there. Advised by Amit Sahai, a computer scientist at the University of California, Los Angeles, the project has already paired 171 incarcerated people in 27 states with a mentor to work on topics from combinatorics to abstract algebra. One participant, Travis Cunningham, is preparing to submit his research in mathematical physics for publication. Most recently, the project has developed a system to let incarcerated mathematicians write computer programs using only the rudimentary “e-mail” system available to people in prison.

Cranking out hundreds of rote calculations per second, computational programming is an invaluable tool for solving problems across diverse disciplines of higher mathematics. For incarcerated people to write computer code without computer access, the Prison Mathematics Project’s programming platform, called the PMP Console, acts as a relay. A person in prison e-mails code from a tablet or kiosk to the console, a cloud-based system extracts and runs the program in an isolated digital environment, and the results are automatically returned.

Havens has already test-driven the console in new work with Carsten Elsner, a mathematician at the University of Applied Sciences for Economics in Hannover, Germany. These latest projects are primarily driven by a specific continued fraction whose nested integers form the sequence 1, 2, 3,…, Elsner says. “We have given [this fraction] the German name *Zopf*.” The name, which translates to “braid,” comes from a conjecture Elsner and Havens are looking to prove: that calculating the greatest common factor among fragments of increasingly precise approximations of *Zopf* produces a twisting pattern where the sequence 1, 2, 3, … alternates with a sequence of ones: 1, 1, 1, 2, 1, 3, 1, 4,…

But the name holds a symbolic meaning as well. In German folklore, a traveling nobleman falls into a swamp, sinking deeper and deeper until the muck threatens to swallow him whole. To escape, he lifts himself out of the bog with his own braid. Elsner “suggested ‘*Zopf’* because of how the numbers twist around the real line and how, in a sense, my life took a similar twisting journey via mathematics,” Havens says. Havens “dealt intensively with [*Zopf*] at the beginning of his mathematical studies,” Elsner adds. “He tried to communicate his results to other mathematicians and thus start the beginning of a better life.”

Although prisoners are interested in the PMP Console—“I’m definitely going to go down that road if I can,” Conway says—the system faces significant obstacles to its widespread use in U.S. prisons. Sending an e-mail in prison can cost up to 50 cents, but inmates only earn, on average, a maximum of 52 cents per hour. And if a prisoner can afford to send code to the console, their message still might never be delivered. “[Prisons] have these rules, which are perfectly reasonable, that you can’t send encoded messages,” Sahai says. “And of course, what they mean by that is enciphered messages.” As Sahai recalls, however, the Prison Mathematics Project was told that “according to the dictionary, you know, computer code is code.”

Help may be coming. Securus Technologies, a major prison-e-mail provider, is “reviewing the possibility” of incorporating the console into its approved education platform, which includes free “e-message exchanges between students and instructors,” says Jade Trombetta, a Securus spokesperson.

But ultimately, whether or not the console sees a broad adaptation, the Prison Mathematics Project isn’t a tech company—it’s an anchoring point for prisoners weaving their own mathematical lifelines. “Until I started studying mathematics, my life had just been chaos and destruction,” says Cunningham, who is serving time for a fatal drunk driving accident. “When I got my first text on partial differential equations, I learned what love is.”

Over the past six years, Cunningham developed his initial “love” of partial differential equations into original research on scattering theory, a framework for describing the effects of collisions among free systems such as between particles or waves. His work, which has been guided by a Massachusetts Institute of Technology–trained mathematician, finds new detail about how “resonances”—the physically significant afterimages of a collision involving a particle or wave**—**are distributed in a simplified quantum mechanical setting. Mathematics “has changed everything for me,” Cunningham says.

To Havens, that transformation forms the core of justice. “Justice is not what happens after a person who committed a crime serves X amount of years,” he says. “Justice happens when you begin to fix what led you [to prison] in the first place.” And although some debts— “infinite debts” as Havens calls them— can never be paid in full, more and more people in prison are turning to mathematics to lift themselves out of the swamp.