login
a(2n+1) = 3*a(2*n) - 4*n with a(0) = 1, a(1) = 3.
2

%I #20 Jul 05 2020 10:59:40

%S 1,3,5,11,7,13,9,15,17,35,19,37,21,39,23,41,25,43,27,45,29,47,31,49,

%T 33,51,53,107,55,109,57,111,59,113,61,115,63,117,65,119,67,121,69,123,

%U 71,125,73,127,75,129,77,131,79,133,81,135,83,137,85,139,87,141,89,143,91

%N a(2n+1) = 3*a(2*n) - 4*n with a(0) = 1, a(1) = 3.

%H Robert Israel, <a href="/A132162/b132162.txt">Table of n, a(n) for n = 0..10000</a>

%F Note (a(2*n+1)-a(2*n))/2 gives A132171.

%F From _Robert Israel_, Feb 24 2017: (Start)

%F a(2*n) = 2*n + A132171(n) = 2*n + 3^floor(log[3](2*n+1)).

%F a(2*n+1) = 2*n + 3*A132171(n) = 2*n + 3*3^floor(log[3](2*n+1)).

%F a(6*n+2) = 4*n+2+a(2*n+1).

%F a(6*n+3) = 2+3*a(2*n+1).

%F a(6*n+4) = 4*n+4+a(2*n+1).

%F a(6*n+5) = 4+3*a(2*n+1).

%F a(6*n+6) = 4*n+6+a(2*n+1).

%F a(6*n+7) = 6+3*a(2*n+1).

%F (End)

%p f:= proc(n) option remember; local j;

%p j:= (n-2) mod 6 + 2;

%p if n::odd then j-1 + 3*procname(1+(n-j)/3)

%p else (2*n+j)/3 + procname(1+(n-j)/3)

%p fi

%p end proc:

%p f(0):= 1: f(1):= 3:

%p map(f, [$0..100]); # _Robert Israel_, Feb 24 2017

%t f[n_] := f[n] = With[{j = Mod[n-2, 6]+2}, If[OddQ[n], j-1 + 3*f[1+(n-j)/3], (2n+j)/3 + f[1+(n-j)/3]]];

%t f[0] = 1; f[1] = 3;

%t f /@ Range[0, 100] (* _Jean-François Alcover_, Jun 22 2020, after Maple *)

%Y Cf. A132171.

%K nonn,look

%O 0,2

%A _Paul Curtz_, Nov 04 2007