%I #16 Sep 05 2017 04:04:38
%S 1,2,3,5,4,6,10,11,9,8,7,12,19,20,21,23,22,18,16,17,15,14,13,24,37,38,
%T 39,41,40,42,46,47,45,44,43,36,31,32,33,35,34,30,28,29,27,26,25,48,73,
%U 74,75,77,76,78,82,83,81,80,79,84,91,92,93,95,94,90,88,89,87,86,85,72
%N a(1)=1, a(2)=2, a(3*2^k) = 3*2^k, a(3*2^k + i) = 3*2^k + a(3*2^k - i), for i in range [1, 3*2^k - 1].
%H Ivan Neretin, <a href="/A096114/b096114.txt">Table of n, a(n) for n = 1..12288</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%t a = {1, 2}; Do[a = Join[a, {3*2^k}, 3*2^k + Reverse[a]], {k, 0, 4}]; a (* _Ivan Neretin_, Sep 04 2017 *)
%o (MIT Scheme:) (define (A096114 n) (cond ((< n 3) n) ((and (zero? (modulo n 3)) (pow2? (/ n 3))) n) (else (let ((lastfix (* 3 (expt 2 (A000523 (floor->exact (/ n 3))))))) (+ lastfix (A096114 (- (* 2 lastfix) n)))))))
%o (define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1)))))
%Y Inverse: A121664. Cf. A096111, A096113, A052330, A096116.
%K nonn
%O 1,2
%A _Amarnath Murthy_, Jun 29 2004
%E Edited, extended and Scheme code added by _Antti Karttunen_, Aug 25 2006