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.

A233279 Permutation of nonnegative integers: a(n) = A054429(A006068(n)).

This page as a plain text file.
%I A233279 #38 Jun 20 2021 21:52:35
%S A233279 0,1,2,3,4,5,7,6,8,9,11,10,15,14,12,13,16,17,19,18,23,22,20,21,31,30,
%T A233279 28,29,24,25,27,26,32,33,35,34,39,38,36,37,47,46,44,45,40,41,43,42,63,
%U A233279 62,60,61,56,57,59,58,48,49,51,50,55,54,52,53,64,65,67,66
%N A233279 Permutation of nonnegative integers: a(n) = A054429(A006068(n)).
%C A233279 This permutation transforms the enumeration system of positive irreducible fractions A007305/A047679 (Stern-Brocot) into the enumeration system A071766/A229742 (HCS), and the enumeration system A162909/A162910 (Bird) into A245325/A245326. - _Yosu Yurramendi_, Jun 09 2015
%H A233279 Antti Karttunen, <a href="/A233279/b233279.txt">Table of n, a(n) for n = 0..8191</a>
%H A233279 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A233279 a(n) = A054429(A006068(n)).
%F A233279 a(n) = A006068(A063946(n)).
%F A233279 a(n) = A154435(A054429(n)).
%F A233279 a(n) = A180200(A258746(n)) = A117120(A180200(n)), n > 0. - _Yosu Yurramendi_, Apr 10 2017
%t A233279 Module[{nn = 6, s}, s = Flatten[Table[Range[2^(n + 1) - 1, 2^n, -1], {n, 0, nn}]]; Map[If[# == 0, 0, s[[#]]] &, Table[Fold[BitXor, n, Quotient[n, 2^Range[BitLength[n] - 1]]], {n, 0, 2^nn}]]] (* _Michael De Vlieger_, Apr 06 2017, after _Harvey P. Dale_ at A054429 and _Jan Mangaldan_ at A006068 *)
%o A233279 (Scheme) (define (A233279 n) (A054429 (A006068 n)))
%o A233279 (R)
%o A233279 maxrow <- 8 # by choice
%o A233279 a <- 1:3
%o A233279 for(m in 0:maxrow) for(k in 0:(2^m-1)){
%o A233279 a[2^(m+2)+            k] <- a[2^(m+1)+    k] + 2^(m+1)
%o A233279 a[2^(m+2)+        2^m+k] <- a[2^(m+1)+2^m+k] + 2^(m+1)
%o A233279 a[2^(m+2)+2^(m+1)+    k] <- a[2^(m+1)+2^m+k] + 2^(m+2)
%o A233279 a[2^(m+2)+2^(m+1)+2^m+k] <- a[2^(m+1)+   +k] + 2^(m+2)
%o A233279 }
%o A233279 (a <- c(0,a))
%o A233279 # _Yosu Yurramendi_, Apr 05 2017
%o A233279 (R)
%o A233279 # Given n, compute a(n) by taking into account the binary representation of n
%o A233279 maxblock <- 7 # by choice
%o A233279 a <- 1
%o A233279 for(n in 2:2^maxblock){
%o A233279   ones <- which(as.integer(intToBits(n)) == 1)
%o A233279   nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
%o A233279   anbit <- nbit
%o A233279   for(k in 2^(0:floor(log2(length(nbit))))  )
%o A233279     anbit <- bitwXor(anbit, c(anbit[-(1:k)], rep(0,k))) # ?bitwXor
%o A233279   anbit[0:(length(anbit) - 1)] <- 1 - anbit[0:(length(anbit)-1)]
%o A233279   a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
%o A233279 }
%o A233279 (a <- c(0,a))
%o A233279 # _Yosu Yurramendi_, May 29 2021
%o A233279 (Python)
%o A233279 from sympy import floor
%o A233279 def a006068(n):
%o A233279     s=1
%o A233279     while True:
%o A233279         ns=n>>s
%o A233279         if ns==0: break
%o A233279         n=n^ns
%o A233279         s<<=1
%o A233279     return n
%o A233279 def a054429(n): return 1 if n==1 else 2*a054429(floor(n/2)) + 1 - n%2
%o A233279 def a(n): return 0 if n==0 else a054429(a006068(n)) # _Indranil Ghosh_, Jun 11 2017
%Y A233279 Inverse permutation: A233280.
%Y A233279 Cf. A006068, A054429, A063946, A154435.
%K A233279 nonn
%O A233279 0,3
%A A233279 _Antti Karttunen_, Dec 18 2013