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.

A153154 Permutation of natural numbers: A059893-conjugate of A006068.

This page as a plain text file.
%I A153154 #16 Oct 08 2021 23:57:31
%S A153154 0,1,3,2,7,4,5,6,15,8,9,14,11,12,13,10,31,16,17,30,19,28,29,18,23,24,
%T A153154 25,22,27,20,21,26,63,32,33,62,35,60,61,34,39,56,57,38,59,36,37,58,47,
%U A153154 48,49,46,51,44,45,50,55,40,41,54,43,52,53,42,127,64,65,126,67,124
%N A153154 Permutation of natural numbers: A059893-conjugate of A006068.
%C A153154 A002487(1+a(n)) = A020651(n) and A002487(a(n)) = A020650(n). So, it generates the enumeration system of positive rationals based on Stern's sequence A002487. - _Yosu Yurramendi_, Feb 26 2020
%H A153154 A. Karttunen, <a href="/A153154/b153154.txt">Table of n, a(n) for n = 0..2047</a>
%H A153154 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A153154 From _Yosu Yurramendi_, Feb 26 2020: (Start)
%F A153154 a(1) = 1, for all n > 0 a(2*n) = 2*a(n) + 1, a(2*n+1) = 2*a(A065190(n)).
%F A153154 a(1) = 1, a(2) = 3, a(3) = 2, for all n > 1 a(2*n) = 2*a(n) + 1, and if n even a(2*n+1) = 2*a(n+1), else a(2*n+1) = 2*a(n-1).
%F A153154 a(n) = A054429(A231551(n)) = A231551(A065190(n)) = A284459(A054429(n)) =
%F A153154        A332769(A284459(n)) = A258996(A154437(n)). (End)
%o A153154 (R)
%o A153154 maxn <- 63 # by choice
%o A153154 a <- c(1,3,2)
%o A153154 #
%o A153154 for(n in 2:maxn){
%o A153154   a[2*n] <- 2*a[n] + 1
%o A153154   if(n%%2==0) a[2*n+1] <- 2*a[n+1]
%o A153154   else        a[2*n+1] <- 2*a[n-1]
%o A153154 }
%o A153154 (a <- c(0,a))
%o A153154 # _Yosu Yurramendi_, Feb 26 2020
%o A153154 (R)
%o A153154 # Given n, compute a(n) by taking into account the binary representation of n
%o A153154 maxblock <- 8 # by choice
%o A153154 a <- c(1, 3, 2)
%o A153154 for(n in 4:2^maxblock){
%o A153154   ones <- which(as.integer(intToBits(n)) == 1)
%o A153154   nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
%o A153154   anbit <- nbit
%o A153154   for(i in 2:(length(anbit) - 1))
%o A153154     anbit[i] <- bitwXor(anbit[i], anbit[i - 1])  # ?bitwXor
%o A153154   anbit[0:(length(anbit) - 1)] <- 1 - anbit[0:(length(anbit) - 1)]
%o A153154   a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
%o A153154 }
%o A153154 (a <- c(0, a))
%o A153154 # _Yosu Yurramendi_, Oct 04 2021
%Y A153154 Inverse: A153153. a(n) = A059893(A006068(A059893(n))).
%K A153154 nonn,base
%O A153154 0,3
%A A153154 _Antti Karttunen_, Dec 20 2008