Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(n):
- B=bin(n)[2:]
- L=len(B)
- M=L//2
- if B=='1'*L:return True
- S=str(int(B[:M])+int(B[:-M-1:-1]))
- if(~L%2==0 and'0'==B[M]) or'2'in S:return False
- if S=='1'*len(S):return True
- return f(int(S,2))
Advertisement
Add Comment
Please, Sign In to add comment