Guest User

Untitled

a guest
Oct 7th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. def f(n):
  2.  B=bin(n)[2:]
  3.  L=len(B)
  4.  M=L//2
  5.  if B=='1'*L:return True
  6.  S=str(int(B[:M])+int(B[:-M-1:-1]))
  7.  if(~L%2==0 and'0'==B[M]) or'2'in S:return False
  8.  if S=='1'*len(S):return True
  9.  return f(int(S,2))
Advertisement
Add Comment
Please, Sign In to add comment