%I #53 Dec 29 2022 06:30:41
%S 1,2,1,5,1,2,1,14,1,2,1,5,1,2,1,41,1,2,1,5,1,2,1,14,1,2,1,5,1,2,1,122,
%T 1,2,1,5,1,2,1,14,1,2,1,5,1,2,1,41,1,2,1,5,1,2,1,14,1,2,1,5,1,2,1,365,
%U 1,2,1,5,1,2,1,14,1,2,1,5,1,2,1,41,1,2,1,5,1,2,1,14,1,2,1,5,1,2,1,122,1,2,1,5
%N Recurrence: a(2n) = 3a(n)-1, a(2n+1) = 1.
%C First differences of Stanley sequence S(0,1) (A005836) and S(1,2) (A003278).
%C In the binary expansion of n, delete everything left of the rightmost 1 bit, then interpret as ternary, add one, and divide by 2.
%C A007051 is this sequence in strictly increasing order. - _Max Barrentine_, Sep 11 2015
%C Empirical: a(n) is the smallest natural number k such that no two adjacent subsequences t and u consisting of consecutive entries of (a(1), a(2), ..., a(n-1), k) are such that the sum of the entries of t is equal to the sum of the entries of u. For example, according to this definition, a(4) cannot be equal to 1, 2, 3, or 4. - _John M. Campbell_, Mar 20 2017
%H T. D. Noe, <a href="/A236313/b236313.txt">Table of n, a(n) for n = 1..10000</a>
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>.
%F a(n) = (1/2)*(1 + 3^A007814(n)) = A007051(A007814(n)).
%F a(n) = (1/2)*A061393(n), for n>=1.
%F Multiplicative with a(2^e) = (1 + 3^e)/2, a(p^e) = 1 for odd prime p. - _Andrew Howroyd_, Jul 31 2018
%F G.f.: Sum_{k>=0} 3^k * x^(2^k) / (1 + x^(2^k)). - _Ilya Gutkovskiy_, Dec 14 2020
%F Dirichlet g.f.: zeta(s)*(2^s-2)/(2^s-3). - _Amiram Eldar_, Dec 29 2022
%t t = {1}; Do[If[OddQ[n], AppendTo[t, 1], AppendTo[t, 3*t[[n/2]] - 1]], {n, 2, 100}]; t (* _T. D. Noe_, Apr 10 2014 *)
%t a[n_] := a[n] =If[OddQ@ n, 1, 3 a[n/2] - 1]; Array[a, 92] (* _Robert G. Wilson v_, Jul 31 2018 *)
%o (PARI) a(n)=(1+3^valuation(n,2))/2
%o (Magma) [(1+3^Valuation(n,2))/2: n in [1..100]]; // _Bruno Berselli_, Jan 22 2014
%Y Cf. A003278, A005836, A006519, A007051, A007814, A061393, A093682.
%K nonn,mult
%O 1,2
%A _Ralf Stephan_, Jan 22 2014