A054429 Simple self-inverse permutation of natural numbers: List each block of 2^n numbers (from 2^n to 2^(n+1) - 1) in reverse order.
1, 3, 2, 7, 6, 5, 4, 15, 14, 13, 12, 11, 10, 9, 8, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 127, 126, 125, 124, 123, 122, 121
Offset: 1
Links
Crossrefs
Programs
-
Haskell
a054429 n = a054429_list !! (n-1) a054429_list = f [1..] where f xs@(x:_) = reverse us ++ f vs where (us, vs) = splitAt x xs -- Reinhard Zumkeller, Jun 01 2015, Feb 21 2014
-
Maple
A054429 := n -> 3*2^ilog2(n) - n - 1: seq(A054429(n), n = 1..70); # [Updated by Peter Luschny, Apr 24 2024]
-
Mathematica
Flatten[Table[Range[2^(n+1)-1,2^n,-1],{n,0,6}]] (* Harvey P. Dale, Dec 17 2013 *)
-
PARI
A054429(n)= 3<<#binary(n\2)-n-1 \\ M. F. Hasler, Aug 18 2014
-
Python
from itertools import count, islice def A054429_gen(): # generator of terms return (m for n in count(0) for m in range((1<
A054429_list = list(islice(A054429_gen(),30)) # Chai Wah Wu, Jul 27 2023 -
R
maxblock <- 10 # by choice a <- NULL for(m in 0:maxblock) a <- c(a, rev(2^m:(2^(m+1)-1))) a # Yosu Yurramendi, Mar 10 2017
Formula
a(n) = ReflectBinTreePermutation(n).
a(n) = if n=1 then 1 else 2*a(floor(n/2)) + 1 - n mod 2. - Reinhard Zumkeller, Feb 18 2003
G.f.: 1/(1-x) * ((x-2x^2)/(1-x) + Sum_{k>=0} 3*2^k*x^2^k). - Ralf Stephan, Sep 15 2003
A115310(n, 1) = a(n). - Reinhard Zumkeller, Jan 20 2006
a(1) = 1, a(2^(m+1) + k) = a(2^m+k) + 2^(m+1),
a(2^(m+1) + 2^m+k) = a(2^m+k) + 2^m, m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Apr 06 2017
a(n) = A117120(A063946(n)) = A063946(A117120(n)) = A092569(A065190(n)) = A065190(A092569(n)), n > 0. - Yosu Yurramendi, Apr 10 2017
a(n) = 3*A053644(n) - n - 1. - Alan Michael Gómez Calderón, Feb 28 2025
Comments