Apex › Storage & databases

Karatsuba multiplication — beating n²

Schoolbook multiplication of two n-digit numbers costs n² single-digit multiplies. In 1960 Karatsuba found you only need three half-size products, not four — because the middle term ad+bc equals (a+b)(c+d) − ac − bd. Recurse and n² collapses to n^1.585, which is why every big-integer library (and thus RSA/ECC key math) uses it. Enter two numbers and watch the recursion split into threes.

More in Storage & databases