%I #14 Jun 30 2020 00:14:11
%S 1,1,3,7,21,61,183,543,1629,4873,14619,43815,131445,394213,1182639,
%T 3547551,10642653,31926873,95780619,287338599,862015797,2586037645,
%U 7758112935,23274309567,69822928701,209468698473,628406095419
%N a(0) = 1, a(1) = 1; for n>0, a(2*n) = 3*a(2n-1), a(2*n+1) = 3*a(2*n) - 2*a(n-1).
%C The sequence of first differences of these numbers (2, 4, 14, 40 ...), divided by 2, is (1, 2, 7, 20, ...) - see A111017. This is close to the original sequence.
%C ..... 1, 1, 3, 7, 21, 61, 183, 543, 1629, 4873, 14619
%C ........ 1, 2, 7, 20, 61, 180, 543, 1622, 4873, 14598
%C ....... 2=3-1, 20=21-1, 180=183-3, 1622=1629-7, 14598=14619-21.
%H Robert Israel, <a href="/A102877/b102877.txt">Table of n, a(n) for n = 0..2095</a>
%F G.f. g(z) satisfies g(z) = 1 - 2*z + 3*z*g(z) - 2*z^3*g(z^2). - _Robert Israel_, Jun 29 2020
%p f:= proc(n) option remember; if n::even then 3*procname(n-1) else 3*procname(n-1)-2*procname((n-3)/2) fi end proc:
%p f(0):= 1: f(1):= 1:
%p map(f, [$0..50]); # _Robert Israel_, Jun 29 2020
%t a[0]:=1;a[1]:=1;a[n_]:=If[EvenQ[n],3*a[n-1],3*a[n-1]-2*a[(n-3)/2]]; Table[a[i],{i,0, 50}] (* _Stefan Steinerberger_, May 22 2007 *)
%o (PARI) {m=26; v=vector(m+1); v[1]=1; v[2]=1; for(n=2, m, k=3*v[n]; if(n%2==1, k=k-2*v[(n-1)/2]); v[n+1]=k); print(v)} /* _Klaus Brockhaus_, May 20 2007 */
%Y This sequence is connected with A129770 and A129772.
%K nonn
%O 0,3
%A _Paul Curtz_, May 16 2007
%E More terms from _Klaus Brockhaus_ and _Stefan Steinerberger_, May 20 2007