def karatsuba(x, y, b=10):
 if ((x < 1000) or (y < 1000)):
  return (x * y)
 m = min((len(str(x)) / 2), (len(str(y)) / 2))
 bm = (b ** m)
 (x1, x0) = ((x / bm), (x % bm))
 (y1, y0) = ((y / bm), (y % bm))
 z1 = karatsuba(x1, y1, b)
 z3 = karatsuba(x0, y0, b)
 z2 = ((karatsuba((x1 + x0), (y1 + y0), b) - z1) - z3)
 return ((((bm ** 2) * z1) + (bm * z2)) + z3)

def karatsuba ( x , y , b = 10 ) : if ( ( x < 1000 ) or ( y < 1000 ) ) : return ( x * y ) m = min ( ( len ( str ( x ) ) / 2 ) , ( len ( str ( y ) ) / 2 ) ) bm = ( b ** m ) ( x1 , x0 ) = ( ( x / bm ) , ( x % bm ) ) ( y1 , y0 ) = ( ( y / bm ) , ( y % bm ) ) z1 = karatsuba ( x1 , y1 , b ) z3 = karatsuba ( x0 , y0 , b ) z2 = ( ( karatsuba ( ( x1 + x0 ) , ( y1 + y0 ) , b ) - z1 ) - z3 ) return ( ( ( ( bm ** 2 ) * z1 ) + ( bm * z2 ) ) + z3 )
returns product of x .