#by using increment
n1=int(input('enter first number:'))
n2=int(input('enter second number:'))
for i in range(1,n2+1):
n1+=1
print(n1)
#by using AND (&) and XOR(A)
n1=int(input('enter first number:'))
n2=int(input('enter second number:'))
while(n2!=0):
carry=n1&n2
n1=n1^n2
n2=carry<<1
print(n1)
#Subtraction without '-' operator
n1=int(input('enter first number:'))
n2=int(input('enter second number:'))
while(n2!=0):
n1=n1^n2
carry=n1&n2
n2=carry<<1
print(n1)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter