login
A269167
Permutation of natural numbers: a(1) = 1, a(A269160(n)) = 2*a(n), a(A269164(n+1)) = 1+(2*a(n)).
3
1, 3, 7, 15, 31, 63, 2, 127, 5, 255, 11, 511, 14, 6, 23, 1023, 29, 13, 47, 2047, 59, 27, 95, 4095, 4, 126, 62, 30, 119, 55, 191, 8191, 9, 253, 125, 61, 239, 111, 383, 16383, 19, 507, 251, 123, 479, 223, 767, 32767, 46, 12, 28, 1022, 22, 510, 39, 254, 1015, 503, 247, 959, 447, 1535, 10, 65535, 93, 25, 57, 2045, 45
OFFSET
1,2
FORMULA
a(1) = 1, for n > 1, if A269162(n) > 0 [when n is in A269163], a(n) = 2*a(A269162(n)), otherwise [when n is in A269164], a(n) = 1 + 2*a(A269169(n)-1).
MATHEMATICA
terms = 100; A269160[n_] := BitXor[n, BitOr[2 n, 4 n]]; f[max_] := f[max] = (s = Sort[Table[A269160[n], {n, 0, max}]]; Complement[Range[Last[s]], s][[1 ;; terms]]); f[terms]; f[max = 2 terms]; While[f[max] != f[max/2], max = 2 max]; A269164[n_] := f[max][[n]]; a[1]=1; eq[n_] := a[A269160[n]] == 2*a[n] && a[A269164[n+1]] == 1 + 2*a[n]; A269167 = Array[a, terms-1] /. Solve[Array[eq, terms-1]] // First (* Jean-François Alcover, Feb 23 2016 *)
PROG
(Scheme, with memoization-macro definec)
(definec (A269167 n) (cond ((= 1 n) n) ((not (zero? (A269162 n))) (* 2 (A269167 (A269162 n)))) (else (+ 1 (* 2 (A269167 (- (A269169 n) 1)))))))
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 21 2016
STATUS
approved