A266341 If A036987(n) = 1, a(n) = n - A053644(n), otherwise a(n) = n - A053644(n) + 2^(A063250(n)-1).
0, 0, 1, 1, 2, 3, 3, 3, 4, 5, 6, 7, 6, 7, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 12, 13, 14, 15, 14, 15, 15, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 24, 25, 26, 27, 28, 29, 30, 31, 28, 29, 30, 31, 30, 31, 31, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50
Offset: 0
Examples
For n=13, "1101" in binary, we remove the most significant bit to get "101", where the most significant nonleading 0 is then filled with that 1, to get "111", which is 7's binary representation, thus a(13) = 7. For n=15, "1111" in binary, we remove the most significant bit to get "111" (= 7), and as there is no most significant nonleading 0 present, the result is just that, and a(15) = 7. For n=21, "10101" in binary, removing the most significant bit and moving it to the position of next zero results "1101", thus a(21) = 13.
Links
- Antti Karttunen, Table of n, a(n) for n = 0..8191
- T. Kubo and R. Vakil, On Conway's recursive sequence, Discr. Math. 152 (1996), 225-252.
Programs
-
PARI
a(n) = my(s=bitnegimply(n>>1,n)); n - if(n,1<
Kevin Ryde, Jun 15 2023 -
Python
from sympy import catalan def a063250(n): if n<2: return 0 b=bin(n)[2:] s=0 while b.count("0")!=0: N=int(b[-1] + b[:-1], 2) s+=1 b=bin(N)[2:] return s def a053644(n): return 0 if n==0 else 2**(len(bin(n)[2:]) - 1) def a036987(n): return catalan(n)%2 def a(n): return n - a053644(n) if a036987(n)==1 else n - a053644(n) + 2**(a063250(n) - 1) # Indranil Ghosh, May 25 2017
Comments