OFFSET
1,7
COMMENTS
When x and y are both 2 or more digits and the larger is L digits long, base b = 10^floor(L/2) is chosen as a split point for those digits with x = xhi*b + xlo and y = yhi*b + ylo.
K(x,y) then makes 3 recursive calls to K(xhi,yhi), K(xlo,ylo) and K(xhi+xlo,yhi+ylo) (and those results can be assembled to make product x*y).
The initial K call and all further recursive calls are counted in a(n).
1 initial call and then 3 recursive calls each time means a(n) == 1 (mod 3).
LINKS
Wikipedia, Karatsuba algorithm
PROG
(Python)
counter = 0
def K(x: int, y: int) -> int:
global counter; counter += 1
if x < 10 or y < 10: return x * y
digits = max(len(str(x)), len(str(y))) // 2
base = 10 ** digits
a, b = divmod(x, base)
c, d = divmod(y, base)
x = K(b, d)
y = K(a + b, c + d)
z = K(a, c)
return z * 10**(digits * 2) + (y - z - x) * base + x
def a(n: int) -> int:
from sympy import fibonacci
global counter; counter = 0
K(fibonacci(n), fibonacci(n + 1))
return counter
print([a(n) for n in range(1, 66)])
CROSSREFS
KEYWORD
nonn
AUTHOR
Darío Clavijo, Jan 09 2025
STATUS
approved