cp's OEIS Frontend

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.

A332769 Permutation of the positive integers: a(n) = A258996(A054429(n)) = A054429(A258996(n)).

This page as a plain text file.
%I A332769 #30 Apr 24 2021 18:51:54
%S A332769 1,3,2,5,4,7,6,13,12,15,14,9,8,11,10,21,20,23,22,17,16,19,18,29,28,31,
%T A332769 30,25,24,27,26,53,52,55,54,49,48,51,50,61,60,63,62,57,56,59,58,37,36,
%U A332769 39,38,33,32,35,34,45,44
%N A332769 Permutation of the positive integers: a(n) = A258996(A054429(n)) = A054429(A258996(n)).
%C A332769 Sequence is self-inverse: a(a(n)) = n.
%C A332769 A002487(1+a(n)) = A162911(n) and A002487(a(n)) = A162912(n). So, a(n) generates the enumeration system of positive rationals based on Stern's sequence A002487 called 'drib'.
%C A332769 Given n, one can compute a(n) by taking into account the binary representation of n, and by flipping every second bit starting from the lowest until reaching the highest 1, which is not flipped.
%H A332769 Yosu Yurramendi, <a href="/A332769/b332769.txt">Table of n, a(n) for n = 1..8191</a>
%F A332769 a(A054429(n)) = A054429(a(n)) = A258996(n),
%F A332769 a(A258996(n)) = A258996(a(n)) = A054429(n).
%F A332769 a(n) = A284447(A065190(n)) = A065190(A284447(n)),
%F A332769 a(A065190(n)) = A065190(a(n)) = A284447(n),
%F A332769 a(A284447(n)) = A284447(a(n)) = A065190(n).
%F A332769 a(A231551(n)) = A154437(n), a(A154437(n)) = A231551(n).
%F A332769 a(A153154(n)) = A284459(n), a(A284459(n)) = A153154(n).
%F A332769 a(1) = 1, a(2) = 3, a(3) = 2; for n > 3, a(2*n) = 2*a(A054429(n)) + 1, a(2*n+1) = 2*a(A054429(n)).
%F A332769 a(1) = 1; for m >= 0 and 0 <= k < 2^m, a(2^(m+1)+2*k) = 2*a(2^(m+1)-1-k) + 1, a(2^(m+1)+2*k+1) = 2*a(2^(m+1)-1-k).
%e A332769 n = 23 =  10111_2
%e A332769             x x
%e A332769           10010_2 = 18 = a(n).
%e A332769 n = 33 = 100001_2
%e A332769           x x x
%e A332769          110100_2 = 52 = a(n).
%o A332769 (R)
%o A332769 maxrow <- 6 # by choice
%o A332769 a <- 1
%o A332769 for(m in 0:maxrow) for(k in 0:(2^m-1)){
%o A332769 a[2^(m+1)+2*k  ] <- 2*a[2^(m+1)-1-k] + 1
%o A332769 a[2^(m+1)+2*k+1] <- 2*a[2^(m+1)-1-k]
%o A332769 }
%o A332769 a
%o A332769 (R) # Given n, compute a(n) by taking into account the binary representation of n
%o A332769 maxblock <- 7 # by choice
%o A332769 a <- c(1, 3, 2)
%o A332769 for(n in 4:2^maxblock){
%o A332769   ones <- which(as.integer(intToBits(n)) == 1)
%o A332769   nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
%o A332769   anbit <- nbit
%o A332769   anbit[seq(1, length(anbit) - 1, 2)] <- 1 - anbit[seq(1, length(anbit) - 1, 2)]
%o A332769   a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
%o A332769 }
%o A332769 a
%o A332769 # _Yosu Yurramendi_, Mar 30 2021
%o A332769 (PARI) a(n) = bitxor(n, 2<<bitor(logint(n,2)-1,1)\3); \\ _Kevin Ryde_, Mar 30 2021
%Y A332769 Similar R-programs: A258996, A284447.
%K A332769 nonn
%O A332769 1,2
%A A332769 _Yosu Yurramendi_, Feb 23 2020