OFFSET
1,2
COMMENTS
The permutation is self-inverse. Except for fixed points 1, 2, 3, 4, 5, 6, 7 it consists completely of 2-cycles: (8,12), (9,13), (10,14), (11,15), (16,20), (17,21), (18,22), (19,23), (24,28), (25,29), (26,30), (27,31), (32,52), (33,53), (34,54), (35,55), (36,48), (37,49), (38,50), (39,51), (40,60), ...
LINKS
Yosu Yurramendi, Table of n, a(n) for n = 1..32767
PROG
(R)
maxrow <- 8 # by choice
a <- 1:3
for(m in 1:maxrow) for(k in 0:(2^m-1)){
if(m%%2 == 1){a[2^(m+1)+ k] <- a[2^m+k] + 2^m
a[2^(m+1)+2^m+k] <- a[2^m+k] + 2^(m+1)}
else {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}
}
a
# Yosu Yurramendi, Apr 06 2017
(R) # Given n, compute a(n) by taking into account the binary representation of n
maxblock <- 7 # by choice
a <- 1:7
for(n in 8:2^maxblock){
ones <- which(as.integer(intToBits(n)) == 1)
nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
anbit <- nbit
anbit[seq(3, length(anbit) - 1, 2)] <- 1 - anbit[seq(3, length(anbit) - 1, 2)]
a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
}
a
# Yosu Yurramendi, Mar 30 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Yosu Yurramendi, Apr 06 2017
STATUS
approved