- #! /usr/bin/env python
- # coding: utf-8
- def newadd(x,y):
- if not y:
- return x
- sum1=x^y
- temp=(x>y)<<1
- return newadd(sum1,temp)
- if __name__=='__main__':
- a=int(raw_input("please inter the first number:"))
- b=int(raw_input("please inter the second number:"))
- print newadd(a,b)
整体思路是通过位的运算来实现。