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 A254104 #21 Mar 24 2021 09:52:00 %S A254104 0,1,2,3,5,4,7,11,6,9,15,10,23,13,8,19,31,14,21,47,22,27,17,12,39,63, %T A254104 18,29,43,30,95,45,20,55,35,46,25,79,26,127,37,16,59,87,38,61,191,62, %U A254104 91,41,28,111,71,42,93,51,94,159,53,44,255,75,54,33,119,34,175,77,24,123,383,78,125,183,126,83,57,36,223,143,58,85,187,86,103,189,60 %N A254104 Permutation of natural numbers: a(0) = 0, a(3n) = 1 + 2*a(2n - 1), a(3n+1) = 1 + 2*a(2n), a(3n+2) = 2*a(n+1). %H A254104 Antti Karttunen, <a href="/A254104/b254104.txt">Table of n, a(n) for n = 0..9842</a> %H A254104 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A254104 a(0) = 0, a(3n) = 1 + 2*a(2n - 1), a(3n+1) = 1 + 2*a(2n), a(3n+2) = 2*a(n+1). %F A254104 Other identities: %F A254104 a(A007051(n)) = 2^n for all n >= 0. [A property shared with A064216.] %o A254104 (Scheme, with memoizing macro definec) %o A254104 (definec (A254104 n) (cond ((< n 1) n) ((= 2 (modulo n 3)) (* 2 (A254104 (/ (+ n 1) 3)))) (else (+ 1 (* 2 (A254104 (+ -1 (inv_for_A032766 n)))))))) %o A254104 (define (inv_for_A032766 n) (+ (* 2 (floor->exact (/ n 3))) (modulo n 3))) %o A254104 (Python) %o A254104 def a(n): %o A254104 if n==0: return 0 %o A254104 if n%3==0: return 1 + 2*a(2*n//3 - 1) %o A254104 elif n%3==1: return 1 + 2*a(2*(n - 1)//3) %o A254104 else: return 2*a((n - 2)//3 + 1) %o A254104 print([a(n) for n in range(101)]) # _Indranil Ghosh_, Jun 06 2017 %Y A254104 Inverse: A254103. %Y A254104 Cf. A007051, A016789, A032766, A064216, A253887. %K A254104 nonn %O A254104 0,3 %A A254104 _Antti Karttunen_, Jan 25 2015