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.
%I A258746 #47 Mar 15 2025 18:39:42 %S A258746 1,2,3,5,4,7,6,10,11,8,9,14,15,12,13,21,20,23,22,17,16,19,18,29,28,31, %T A258746 30,25,24,27,26,42,43,40,41,46,47,44,45,34,35,32,33,38,39,36,37,58,59, %U A258746 56,57,62 %N A258746 Permutation of the positive integers: this permutation transforms the enumeration system of positive irreducible fractions A007305/A047679 (Stern-Brocot) into the enumeration system A162909/A162910 (Bird), and vice versa. %C A258746 As A117120 the permutation is self-inverse. Except for fixed points 1, 2, 3 it consists completely of 2-cycles: (4,5), (6,7), (8,10), (9,11), (12,14), (13,15), (16,21), (17,20), ..., (24,29), ..., (32,42), ... . %H A258746 Yosu Yurramendi, <a href="/A258746/b258746.txt">Table of n, a(n) for n = 1..20001</a> %H A258746 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A258746 a(1) = 1, a(2) = 2, a(3) = 3. For n >= 2, m = floor(log_2(n)). If m even, then a(2*n) = 2*a(n) and a(2*n+1) = 2*a(n)+1. If m odd, then a(2*n) = 2*a(n)+1 and a(2*n+1) = 2*a(n). %F A258746 From _Yosu Yurramendi_, Mar 23 2017: (Start) %F A258746 A258996(a(n)) = a(A258996(n)) for n > 0; %F A258746 A117120(a(n)) = a(A117120(n)) for n > 0; %F A258746 A092569(a(n)) = a(A092569(n)) for n > 0; %F A258746 A063946(a(n)) = a(A063946(n)) for n > 0; %F A258746 A054429(a(n)) = a(A054429(n)) = A165199(n) for n > 0; %F A258746 A065190(a(n)) = a(A065190(n)) for n > 0. (End) %F A258746 a(n) = A054429(A165199(n)). - _Alan Michael Gómez Calderón_, Mar 08 2025 %o A258746 (R) %o A258746 a <- 1:3 %o A258746 maxn <- 50 # by choice %o A258746 # %o A258746 for(n in 2:maxn){ %o A258746 m <- floor(log2(n)) %o A258746 if(m%%2 == 0) { %o A258746 a[2*n ] <- 2*a[n] %o A258746 a[2*n+1] <- 2*a[n]+1 } %o A258746 else { %o A258746 a[2*n ] <- 2*a[n]+1 %o A258746 a[2*n+1] <- 2*a[n] } %o A258746 } %o A258746 # %o A258746 a %o A258746 # _Yosu Yurramendi_, Jun 09 2015 %o A258746 (R) %o A258746 # Given n, compute a(n) by taking into account the binary representation of n %o A258746 maxblock <- 7 # by choice %o A258746 a <- 1:3 %o A258746 for(n in 4:2^maxblock){ %o A258746 ones <- which(as.integer(intToBits(n)) == 1) %o A258746 nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)] %o A258746 anbit <- nbit %o A258746 ifelse(floor(log2(n)) %% 2 == 0, %o A258746 anbit[seq(1, length(anbit)-1, 2)] <- 1 - anbit[seq(1, length(anbit)-1, 2)], %o A258746 anbit[seq(2, length(anbit) - 1, 2)] <- 1 - anbit[seq(2, length(anbit)-1, 2)]) %o A258746 a <- c(a, sum(anbit*2^(0:(length(anbit)-1)))) %o A258746 } %o A258746 a %o A258746 # _Yosu Yurramendi_, May 29 2021 %Y A258746 Cf. A117120. %K A258746 nonn %O A258746 1,2 %A A258746 _Yosu Yurramendi_, Jun 09 2015