The Greek mathematician Euclid was able to prove around 300 BC that there are infinitely many prime numbers. But British mathematician Christian Lawson-Perfect recently devised a computer game. “Is this the main thing?”

Launched five years ago, the game surpassed three million attempts on July 16 – or, more accurately, hit 2,999,999 – after Hacker News post it generated a wave of about 100,000 attempts.

The object of the game is to classify as many numbers as possible in 60 seconds into “basic” or “inappropriate” (as Lawson-Perfect originally described to na Aperiodicl, a mathematical blog whose founder and editor).

A prime number is an integer with exactly two divisors, 1 and alone.

“It’s very simple, but outrageous,” says Lawson-Perfect, who works in the e-learning unit at the University of Newcastle School of Mathematics and Statistics. He created the game in his spare time, but it proved useful in business: Lawson-Perfect writes e-assessment software (systems that assess learning). “The system I’m making is designed to randomly generate math questions and take an answer from students, which automatically marks and gives feedback,” he says. “You could look at a simple game as a kind of assessment” – he used it when holding field sessions in schools.

It made the keyboard shortcut a bit easier – the yin keys click the appropriate yes-no buttons on the screen to save time moving the mouse.

Vortex:

**Primarity check algorithms**

Prime numbers have a practical benefit in computing – such as error correction and encryption codes. But while primary factorization is difficult (hence its value in encryption), checking primacy is easier, though inconvenient. German mathematician winner of the Fields Medal Alexander Grothendieck infamously wrong 57 for Prime Minister (“Grothendieck prime”). When Lawson-perfect analyzed data from the game, found that different numbers show a certain “grothendieckyness”. The number most often replaced with a prime number was 51, followed by 57, 87, 91, 119, and 133 – Lawson-Perfect’s Enemy (he also devised a useful primacy check service: https://isthisprime.com/2).

The most minimalist algorithm for checking the correctness of a number is trial division – divide the number with each number up to its square root (the product of two numbers greater than the square root would be greater than the number in question).

However, this naive method is not very effective, nor are some other techniques devised over the centuries – as the German mathematician Carl Friedrich Gauss observed in 1801, “require unbearable work for even the most tireless calculator.”

The algorithm that Lawson-Perfect coded for the game is called the Miller-Rabin primacy test (which is based on a very efficient but not 17th-century iron method, “Fermat’s small theorem”). The Miller-Rabin test works surprisingly well. As for Lawson-Perfect, it’s “basically magic” – “I don’t really understand how it works, but I’m sure I could if I took the time to look at it more deeply,” he says.

Because the test uses chance, it gives a probabilistic result. Which means sometimes the test lies. “There’s a chance to discover a fraud, a complex number trying to pass as a base,” says Carl Pomerance, a mathematician at Dartmouth College and co-author of the book. *Prime numbers: computational perspective*. The chances of a cheater slipping through the smart algorithm check mechanism are perhaps one in a billion, so the test is “pretty safe”.

But when it comes to smart algorithms for checking primacy, the Miller-Rabin test is “the tip of the iceberg,” Pomerance says. 19 years ago, three computer scientists – Manindra Agrawal, Neeraj Kayal and Nitin Saxena, all from the Kanpur Indian Institute of Technology – announced ACS primacy test (again following Fermat’s method), who finally provided a test to unequivocally prove that the number is simple, without random selection, and (at least theoretically) with impressive speed. Alas, fast in theory does not always mean fast in real life, so the AKS test is not useful for practical purposes.

**Unofficial world record**

But practicality is not always important. Occasionally Lawson-Perfect receives emails from people who want to share their best results in the game. Recently, a player reported 60 copies in 60 seconds, but the record is more likely to be 127 (Lawson-Perfect does not track high scores; he knows there are some cheats, with computer attempts leading to data jumps).

Score 127 was achieved by Ravi Fernando, a math graduate from the University of California, Berkeley, who announced the result in July 2020. It is still his personal record and, he reckons, an “unofficial world record”.

Since last summer, Fernando hasn’t played the game with the default settings much, but he has tried custom settings, opting for higher numbers and allowing longer time limits – he scored 240 with a five-minute limit. “Which required a lot of speculation, because the numbers went into a high four-digit range, and I only remembered numbers up to 3,000,” he says. “I guess some would argue that that’s too much, too.”

Fernando’s research deals with algebraic geometry, which to some extent includes prime numbers. But, he says, “my research has more to do with why I stopped playing the game than why I started” (he received his doctorate in 2014). In addition, he believes 127 would be very difficult to win. And, he says, “it’s just right to stop at a record number.”