A081154 Number of odd cycles in range [A014137(2n)..A014138(2n)] of permutation A057505/A057506, with no fixed points of either A057163 or A057164.
0, 0, 2, 6, 18, 50, 142, 388, 1114
Offset: 0
Formula
a(n) = A081153(2n+1).
This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
To obtain the signature permutation, we apply these transformations to the binary trees as encoded and ordered by A014486 and for each n, a(n) will be the position of the tree to which the n-th tree is transformed to, as follows: . one tree of one internal empty tree (non-leaf) node x \/ n= 0 1 a(n)= 0 1 (both are always fixed) . the next 7 trees, with 2-3 internal nodes, in range [A014137(1), A014137(2+1)-1] = [2,8] are: . \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \_/ \/ \/ n= 2 3 4 5 6 7 8 . and the new shapes after swapping their left and right hand subtrees are: . \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \_/ \/ \/ a(n)= 3 2 7 8 6 4 5 thus we obtain the first nine terms of this sequence: 0, 1, 3, 2, 7, 8, 6, 4, 5.
a(10)=14 and a(14)=10, A014486[10] = 172 (10101100 in binary), A014486[14] = 202 (11001010 in binary) and these encode the following mountain ranges (and the corresponding rooted plane trees), which are reflections of each other: ...../\___________/\ /\/\/__\_________/__\/\/\ ... ...../...........\ ..\|/.............\|/
a(n) = CatalanRankGlobal(runcounts2binexp(reverse(binexp2runcounts(A014486[n])))) # i.e., reverse and complement the totally balanced binary sequences
See Links section.
map(CatalanRankGlobal,map(DonagheysM, A014486)); or map(CatalanRankGlobal,map(DeepRotateTriangularization, A014486)); DonagheysM := n -> pars2binexp(DonagheysMP(binexp2pars(n))); DonagheysMP := h -> `if`((0 = nops(h)),h,[op(DonagheysMP(car(h))),DonagheysMP(cdr(h))]); DeepRotateTriangularization := proc(nn) local n,s,z,w; n := binrev(nn); z := 0; w := 0; while(1 = (n mod 2)) do s := DeepRotateTriangularization(BinTreeRightBranch(n))*2; z := z + (2^w)*s; w := w + binwidth(s); z := z + (2^w); w := w + 1; n := floor(n/2); od; RETURN(z); end;
(define (FORK foo) (letrec ((bar (lambda (s) (let ((t (foo s))) (if (pair? t) (cons (bar (car t)) (bar (cdr t))) t))))) bar)) (define (!FORK foo!) (letrec ((bar! (lambda (s) (cond ((pair? s) (foo! s) (bar! (car s)) (bar! (cdr s)))) s))) bar!))
map(CatalanRankGlobal,map(DonagheysA057506,CatalanSequences(196))); # Where CatalanSequences(n) gives the terms A014486(0..n). DonagheysA057506 := n -> pars2binexp(deepreverse(DonagheysA057505(deepreverse(binexp2pars(n))))); DonagheysA057505 := h -> `if`((0 = nops(h)), h, [op(DonagheysA057505(car(h))), DonagheysA057505(cdr(h))]); # The following corresponds to automorphism A057164: deepreverse := proc(a) if 0 = nops(a) or list <> whattype(a) then (a) else [op(deepreverse(cdr(a))), deepreverse(a[1])]; fi; end; # The rest of required Maple-functions: see the given OEIS Wiki page.
(define (A057506 n) (CatalanRankSexp (*A057506 (CatalanUnrankSexp n)))) (define (*A057506 bt) (let loop ((lt bt) (nt (list))) (cond ((not (pair? lt)) nt) (else (loop (cdr lt) (cons nt (*A057506 (car lt)))))))) ;; Functions CatalanRankSexp and CatalanUnrankSexp can be found at OEIS Wiki page.
map(CatalanRankGlobal,map(RotateHandshakes, A014486)); RotateHandshakes := n -> pars2binexp(RotateHandshakesP(binexp2pars(n))); RotateHandshakesP := h -> `if`((0 = nops(h)),h,[op(car(h)),cdr(h)]); # This does the trick! In Lisp: (defun RotateHandshakesP (h) (append (car h) (list (cdr h)))) car := proc(a) if 0 = nops(a) then ([]) else (op(1,a)): fi: end: # The name is from Lisp, takes the first element (head) of the list. cdr := proc(a) if 0 = nops(a) then ([]) else (a[2..nops(a)]): fi: end: # As well. Takes the rest (the tail) of the list. PeelNextBalSubSeq := proc(nn) local n,z,c; if(0 = nn) then RETURN(0); fi; n := nn; c := 0; z := 0; while(1 = 1) do z := 2*z + (n mod 2); c := c + (-1)^n; n := floor(n/2); if(c >= 0) then RETURN((z - 2^(floor_log_2(z)))/2); fi; od; end; RestBalSubSeq := proc(nn) local n,z,c; n := nn; c := 0; while(1 = 1) do c := c + (-1)^n; n := floor(n/2); if(c >= 0) then break; fi; od; z := 0; c := -1; while(1 = 1) do z := 2*z + (n mod 2); c := c + (-1)^n; n := floor(n/2); if(c >= 0) then RETURN(z/2); fi; od; end; pars2binexp := proc(p) local e,s,w,x; if(0 = nops(p)) then RETURN(0); fi; e := 0; for s in p do x := pars2binexp(s); w := floor_log_2(x); e := e * 2^(w+3) + 2^(w+2) + 2*x; od; RETURN(e); end; binexp2pars := proc(n) option remember; `if`((0 = n),[],binexp2parsR(binrev(n))); end; binexp2parsR := n -> [binexp2pars(PeelNextBalSubSeq(n)),op(binexp2pars(RestBalSubSeq(n)))]; # Procedure CatalanRankGlobal given in A057117, other missing ones in A038776.
Comments