######################################################### # # # Coded by Indranil Ghosh (indranilg49@gmail.com) # # # ######################################################### #Python 2.7.11, OEIS sequence: A233277 from sympy import factorial, floor def a054429(n): return 1 if n==1 else 2*a054429(floor(n/2)) + 1 - n%2 def a046699(n): if n<3: return 1 s=1 while factorial(2*s)%(2**(n - 1))>0: s+=1 return s def a053644(n): return 0 if n==0 else 2**(len(bin(n)[2:]) - 1) def a043545(n): x=bin(n)[2:] return int(max(x)) - int(min(x)) def a079559(n): return 1 if n==0 else a043545(n + 1)*a079559(n + 1 - a053644(n + 1)) def a213714(n): return 0 if n==0 else a079559(n)*(a046699(n + 2) - 1) def a234016(n): return n - (a046699(n + 2) - 1) def a234017(n): return (1 - a079559(n))*a234016(n) def a233275(n): return n if n<2 else 2*a233275(a213714(n) - 1) if a079559(n)==1 else 1 + (2*a233275(a234017(n))) def a(n): return 0 if n==0 else a054429(a233275(n)) print [a(n) for n in xrange(101)]