This board is based on D. H. Lehmer's 1982 electronic number sieve design: thirty ATtiny412s in place of his ROM and counter pairs, an RP2040 in place of the controlling computer. The run at the end of the video factors 2^79 − 1, stepped at the 5,000 candidates per second of his 1932 gear machine. It finds the factors in 11.3 seconds, against the 12 seconds he published. At its own 500,000 candidates per second, this board can step 100 times faster than that machine.
How number sieves compute without doing arithmetic
Imagine a room of musicians, each following a repeating pattern of claps. One claps every third count. Another claps on counts 1, 4 and 5 of a repeating 5-count pattern. A conductor counts upward, and if any musician claps on a count, that number is thrown out. A number that passes in silence goes off for a separate, expensive check.
A musician's position in their pattern is just the number modulo that pattern length. So each one is testing a single modulus and rejecting certain values of it. Add musicians and fewer numbers survive, so fewer expensive checks are needed. The count itself never has to slow down, because the conductor is just listening for silence.
Each musician in that room is one physical part in a number sieve. In 1928 the Lehmers used 19 musicians: 19 bicycle chains on a common shaft, one chain per modulus, with a twist of chickenwire at each accepted link tripping a microswitch. The switches were wired in series, so a candidate nobody rejected completed the circuit and stopped the motor. A person then read the revolution counter and did the arithmetic.

The 1932 machine replaced the 19 chains with 30 steel gears, adding eleven more moduli. The switches were replaced by a beam of light through aligned holes, detected by a photoelectric cell.

Every number sieve built since has the same two stages, a fast rejecter and a slower checker [LUKES95]. What changed was only what each stage was made of: bicycle chains, then steel gears, then surplus Navy delay lines, then shift registers, then custom VLSI, going from 50 candidates per second in 1928 to 6.4 billion in 1995.
What can you do with it
Say you want to factor 7663 without trial division. If you can write it as a difference of two squares, a² − b² = 7663, the factors fall out as (a+b)(a−b). Rearranged: a² = b² + 7663. So we search for a b where b² + 7663 is a perfect square.
Any a and b satisfying that must also satisfy it in modular arithmetic. Working mod 5, where 7663 is 3, the only squares are 0, 1 and 4. Writing out b² + 3 for every b mod 5 gives 3, 4, 2, 2, 4, so b cannot be 0, 2 or 3 mod 5. That is one musician on a 5-count pattern, rejecting numbers on counts 0, 2 and 3.
Add mod 7 and b also cannot be 0, 1 or 6 mod 7. The first count where both stay silent is b = 4, which is not a solution. The next is b = 9, and 9² + 7663 = 7744 = 88², giving 7663 = 97 × 79. Two musicians cut the values needing a real test from 9 to 2.
About half the values in a modulus are typically rejected. If the moduli are coprime, those rejections are independent, so k moduli leave roughly 1/2^k of the candidates. Any number theory problem you can write as a whole number equation can be brute forced this way.
One ATtiny per musician
Lehmer's 1982 lecture describes a design using a bank of ROM and counter pairs, one per modulus, stepped together by a shared clock. The rest of this is my implementation based on that design, and not a replica.
I combine all thirty outputs on one line, driven by open collector outputs. These can only pull the line low and never drive it high, so any single card can reject a candidate while the others stay silent. The RP2040 loads the bit patterns, drives the clock, and watches that line. If the line stays high on a count, no...
Read more »
kbsriram



















Tim Wilkinson
MaxBareiss
Ted Fried
Alex Krasno