We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4eb5dcd commit 911394fCopy full SHA for 911394f
1 file changed
bit/add_without_operator.py
@@ -1,21 +1,23 @@
1
"""
2
-The following code adds two numbers without using the '+' operator.
+The following code adds two positive integers without using the '+' operator.
3
The code uses bitwise operations to add two numbers.
4
5
Input: 2 3
6
Output: 5
7
8
9
+
10
def addWithoutOperator(x, y):
11
while y != 0:
12
carry = x & y
13
x = x ^ y
14
y = carry << 1
15
print x
16
17
18
def main():
- x,y = map(int,raw_input().split())
- addWithoutOperator(x,y)
19
+ x, y = map(int, raw_input().split())
20
+ addWithoutOperator(x, y)
21
22
if __name__ == '__main__':
23
main()
0 commit comments