mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-06 22:05:54 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
1c4493ab3f
commit
3f86505897
@ -15,11 +15,12 @@ def add(first: int, second: int) -> int:
|
|||||||
-321
|
-321
|
||||||
"""
|
"""
|
||||||
while second != 0:
|
while second != 0:
|
||||||
carry = first & second # Calculate carry
|
carry = first & second # Calculate carry
|
||||||
first = first ^ second # Add without carry
|
first = first ^ second # Add without carry
|
||||||
second = carry << 1 # Prepare carry for next iteration
|
second = carry << 1 # Prepare carry for next iteration
|
||||||
return first
|
return first
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import doctest
|
import doctest
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user