%I #14 Sep 23 2017 19:55:07
%S 0,1,2,5,2,10,21,4,42,85,10,170,5,4,340,681,20,8,1363,42,2726,5453,8,
%T 10906,11,84,21812,21,170,43624,87249,20,40,174499,340,348998,697997,
%U 10,16,1395995,8,2791990,85,680,5583980,43,1362,168,11167961,40,22335922,44671845,16,89343690,178687381,2726,357374762,341,84,80,23,5452,8,714749525,10906
%N a(1) = 0, a(2) = 1; and for n > 2, a(n) = 2*a(A285712(n)) + [1 == (n mod 3)].
%C Binary expansion of a(n) encodes the positions of numbers of the form 3k+1 (with k >= 1) in the path taken from n to the root in the binary trees A245612 and A244154, except that the most significant 1-bit of a(n) always corresponds to 2 instead of 1 at the root of those trees.
%H Antti Karttunen, <a href="/A292591/b292591.txt">Table of n, a(n) for n = 1..2048</a>
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%H <a href="/index/Pri#prime_indices">Index entries for sequences computed from indices in prime factorization</a>
%F a(n) + A292590(n) = A245611(n).
%F a(A245612(n)) = A292593(n).
%F A000120(a(n)) = A292595(n).
%t f[n_] := f[n] = Which[n == 1, 0, Mod[n, 3] == 2, Ceiling[n/3], True, (Times @@ Power[If[# == 1, 1, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger[2 n - 1] + 1)/2]; a[n_] := a[n] = If[n <= 2, n - 1, 2 a[f@ n] + Boole[Mod[n, 3] == 1]]; Array[a, 65] (* _Michael De Vlieger_, Sep 22 2017 *)
%o (Scheme) (define (A292591 n) (if (<= n 2) (- n 1) (+ (if (= 1 (modulo n 3)) 1 0) (* 2 (A292591 (A285712 n))))))
%Y Cf. A244153, A244154, A245611, A245612, A285712, A292590, A292593, A292595.
%Y Cf. also A292245, A292385 (A292381).
%K nonn
%O 1,3
%A _Antti Karttunen_, Sep 20 2017