The Karatsuba algorithm is a fast multiplication algorithm. Karatsuba multiplication algorithm is named after the Russian mathematician Anatoly Karatsuba. It uses a divide and conquer approach that gives it a running time improvement over the standard “grade-school” method. Read on for Python implementations of both algorithms and a comparison of their running time.
Where a,b,c,d are n/2 digit numbers.
- Break the two integers x and y into a, b, c and d as described above
- Recursively compute ac
- Recursively compute bd
- Recursively compute (a + b)(c + d)
- Calculate (ab + bc) as (a + b)(c + d) – ac – bd
- Let A be ac with n zeros added to the end
- let B be (ab + bc) with half n zeros added to the end
- The final answer is A + B + bd
for more information https://en.wikipedia.org/wiki/Karatsuba_algorithm