######################################################### # # # Coded by Indranil Ghosh (indranilg49@gmail.com) # # # ######################################################### #Python 2.7.11, OEIS sequence: A261076 import gmpy2 from sympy import fibonacci def isfibonacci(n): k=n**2 k+=((k + 1)<<2) return gmpy2.is_square(k) or (n>0 and gmpy2.is_square(k - 8)) def kth(n): # returns the index of the fibonacci number n in the fibonacci sequence i=0 while True: if n==fibonacci(i): return i else: i+=1 def a007895(n): k=0 x=0 while n>0: k=0 while fibonacci(k)<=n: k+=1 x+=10**(k - 3) n-=fibonacci(k - 1) return str(x).count("1") def a219641(n): return n - a007895(n) def a(n): if n<3: return n x=a219641(a(n - 1)) if isfibonacci(x + 1): return fibonacci(kth(x + 1) + 2) - 1 else: return x print [a(n) for n in xrange(0, 101)]