login
A096114
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].
5
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, 39, 41, 40, 42, 46, 47, 45, 44, 43, 36, 31, 32, 33, 35, 34, 30, 28, 29, 27, 26, 25, 48, 73, 74, 75, 77, 76, 78, 82, 83, 81, 80, 79, 84, 91, 92, 93, 95, 94, 90, 88, 89, 87, 86, 85, 72
OFFSET
1,2
MATHEMATICA
a = {1, 2}; Do[a = Join[a, {3*2^k}, 3*2^k + Reverse[a]], {k, 0, 4}]; a (* Ivan Neretin, Sep 04 2017 *)
PROG
(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)))))))
(define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1)))))
CROSSREFS
Sequence in context: A359557 A114744 A352715 * A344169 A121664 A352943
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Jun 29 2004
EXTENSIONS
Edited, extended and Scheme code added by Antti Karttunen, Aug 25 2006
STATUS
approved