login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A266341 If A036987(n) = 1, a(n) = n - A053644(n), otherwise a(n) = n - A053644(n) + 2^(A063250(n)-1). 3
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 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,5
COMMENTS
Informally: In binary representation of n, move the most significant 1-bit to the position of the most significant 0-bit ("the leftmost free hole"), and remove it altogether if there are no such holes, i.e., if n is one of the terms of A000225. When the subsets of nonnegative integers are associated with the binary expansion of n in the usual way (bit-k is 1 if number k is present in the set, and 0 stands for an empty set) then a(n) corresponds to the set obtained by "squashing" the set which corresponds to n. See Kubo & Vakil paper, page 240, 8.1 Compression revisited.
LINKS
T. Kubo and R. Vakil, On Conway's recursive sequence, Discr. Math. 152 (1996), 225-252.
FORMULA
a(0) = 0; after which, for n = 2^k - 1 (when k >= 1) a(n) = 2^(k-1) - 1, otherwise a(n) = n - A053644(n) + 2^(A063250(n)-1).
Equally: if A063250(n) = 0, a(n) = n - A053644(n), otherwise a(n) = n - A053644(n) + 2^(A063250(n)-1).
Other identities. For all n >= 0:
a(n) = A209862(-1+A004001(1+A209861(n))). [Not yet proved that the required permutations are just A209861 & A209862, although this has been checked empirically up to n=32769. See also Kubo & Vakil paper.]
EXAMPLE
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.
PROG
(define (A266341 n) (+ (- n (A053644 n)) (if (zero? (A063250 n)) 0 (A000079 (- (A063250 n) 1)))))
(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
(PARI) a(n) = my(s=bitnegimply(n>>1, n)); n - if(n, 1<<logint(n, 2)) + if(s, 1<<logint(s, 2)); \\ Kevin Ryde, Jun 15 2023
CROSSREFS
Cf. also A004001, A209861, A209862.
Sequence in context: A025772 A211535 A029069 * A279521 A076896 A275890
KEYWORD
nonn,easy
AUTHOR
Antti Karttunen, Jan 13 2016
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 07:53 EDT 2024. Contains 371964 sequences. (Running on oeis4.)