◄ WORLD V · SONNY 5DART 047 · a helldive at the net

CHINESE REMAINDER count without counting

“There are things whose number we do not know. Counted by threes, two remain; by fives, three; by sevens, two. How many things?” That riddle is 1,600 years old, and its answer — that a number is pinned down by its remainders — runs modern cryptography. It runs in real I-13 on the merged %, and gives the ancient answer: 23.

THE TECHNIQUE step by the first modulus until the rest agree

To satisfy several remainder conditions with coprime moduli, walk in steps of one modulus until the next condition holds, then combine and repeat. The remainders uniquely determine the number modulo the product. Solve Sunzi’s riddle, or your own. live demo

HISTORY & CREDIT genuinely Chinese, genuinely ancient

Most “named-after-a-place” theorems are misattributions; this one earns its name — it is Chinese, and it predates Gauss by 1,500 years. cited

3rd–5th c. CE · Sunzi Suanjing poses the counting riddle and gives the answer — possibly for counting soldiers or tallying without a full count.
5th–6th c. · the Indian astronomer Aryabhata (the Aryabhatiya, 499 CE) uses a related method (kuttaka) for calendar cycles.
1247 · Qin Jiushao gives the general algorithm (the “Da Yan” rule) in the Mathematical Treatise in Nine Sections.
1801 · Carl Friedrich Gauss states and proves it in Disquisitiones Arithmeticae — the form now taught, and the backbone of fast RSA (CRT decryption).

A riddle about not counting became the mathematics that counts your bank transactions. foundational

RECOMMEND FOR I-13 the merged % gives the ancient answer

Search in steps of one modulus until the next remainder matches, then merge — pure % and recursion. It runs, and returns Sunzi’s 23:

def crt2(I a1, I n1, I a2, I n2, I x) { if x % n2 == a2 { -> x } -> crt2(a1, n1, a2, n2, x + n1) } I x1 <- crt2(2, 3, 3, 5, 2) // 8 I x2 <- crt2(x1, 15, 2, 7, x1) // 23
$ i13 run crt.i13 x1 = 8 # smallest x = 2 (mod 3), = 3 (mod 5) x2 = 23 # ... and = 2 (mod 7) -- Sunzi's answer
Recommend: nothing new — a no-wall standing entirely on the % the campaign asked for and merged (darts 010/027/032). The constructive CRT (modular inverse via extended Euclid) also runs on the same operator. This is one of the oldest algorithms the darts have thrown, and it needed only the modulo to come home.
Honest note: cryptographic CRT (thousand-bit moduli) hits the bignum ceiling — the same withheld recommend as darts 032/035/041. The method is exact and ancient; only the scale waits on a bignum decision.