Multiplicar números
def multiply_dyv(n1, n2):
# Base case (small enough numbers)
if n1 < 100 or n2 < 100:
return n1 * n2
# Recursive case
else:
# Get the number of digits of the biggest number
n = max(len(str(n1)), len(str(n2)))
n = n // 2 # The number of digits of the half of the numbers
# Split the numbers in two parts
a = n1 // 10**n # First half of n1
b = n1 % 10**n # Second half of n1
c = n2 // 10**n # First half of n2
d = n2 % 10**n # Second half of n2
# Recursive calls
ac = multiply_dyv(a, c) # Recursive call for the first half
bd = multiply_dyv(b, d) # Recursive call for the second half
ab_cd = multiply_dyv(a+b, c+d) - ac - bd # Recursive call for the cross multiplication
# Combine the results
return ac * 10**(2*n) + ab_cd * 10**n + bd
if __name__ == "__main__":
n1 = 123456789012345678901234567890
n2 = 123456789012345678901234567890
result1 = multiply_dyv(n1, n2)
print(result1)