mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Remove unnecessary else statement (#7759)
* Remove unnecessary else statement * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
71e8ed81ae
commit
501a1cf0c7
|
@ -10,18 +10,18 @@ def karatsuba(a, b):
|
|||
"""
|
||||
if len(str(a)) == 1 or len(str(b)) == 1:
|
||||
return a * b
|
||||
else:
|
||||
m1 = max(len(str(a)), len(str(b)))
|
||||
m2 = m1 // 2
|
||||
|
||||
a1, a2 = divmod(a, 10**m2)
|
||||
b1, b2 = divmod(b, 10**m2)
|
||||
m1 = max(len(str(a)), len(str(b)))
|
||||
m2 = m1 // 2
|
||||
|
||||
x = karatsuba(a2, b2)
|
||||
y = karatsuba((a1 + a2), (b1 + b2))
|
||||
z = karatsuba(a1, b1)
|
||||
a1, a2 = divmod(a, 10**m2)
|
||||
b1, b2 = divmod(b, 10**m2)
|
||||
|
||||
return (z * 10 ** (2 * m2)) + ((y - z - x) * 10 ** (m2)) + (x)
|
||||
x = karatsuba(a2, b2)
|
||||
y = karatsuba((a1 + a2), (b1 + b2))
|
||||
z = karatsuba(a1, b1)
|
||||
|
||||
return (z * 10 ** (2 * m2)) + ((y - z - x) * 10 ** (m2)) + (x)
|
||||
|
||||
|
||||
def main():
|
||||
|
|
Loading…
Reference in New Issue
Block a user