login
A266569
a(1) = 1; thereafter a(2k) = 4k + a(k); a(2k+1) = k + a(4k+4).
7
1, 5, 30, 13, 68, 42, 64, 29, 132, 88, 119, 66, 154, 92, 132, 61, 248, 168, 217, 128, 261, 163, 221, 114, 322, 206, 273, 148, 326, 192, 268, 125, 468, 316, 401, 240, 463, 293, 387, 208, 533, 345, 448, 251, 519, 313, 425, 210, 646, 422, 543, 310, 623, 381, 511
OFFSET
1,2
EXAMPLE
For n=2, a(2) = 4 + a(1) = 5.
For n=3:
a(3) = 1 + a(8);
a(8) = 2*8 + a(8/2) = 16 + a(4);
a(4) = 2*4 + a(4/2) = 8 + a(2) = 13;
a(8) = 18+13 = 29;
a(3) = 1 + 29 = 30.
MAPLE
A266569 := proc(n)
option remember;
local k;
if n = 1 then
1;
elif type(n, 'even') then
2*n+procname(n/2) ;
else
k := (n-1)/2 ;
k+procname(4*k+4) ;
end if;
end proc:
seq(A266569(n), n=1..100) ; # R. J. Mathar, May 06 2016
MATHEMATICA
a[1] = 1; a[n_] := a[n] = If[EvenQ@ n, 2 n + a[n/2], (n - 1)/2 + a[2 (n + 1)]]; Array[a, 55] (* Michael De Vlieger, Jan 02 2016 *)
PROG
(Sidef)
func a((1)) { 1 }
func a(n {.is_even}) is cached { 2*n + a(n/2) }
func a(n {.is_odd }) is cached { (n-1)/2 + a(2*(n + 1)) }
1000.times { |n| say a(n) }
CROSSREFS
Records (high water marks): A270811, A270812.
Sequence in context: A237256 A172041 A187605 * A098346 A134166 A154522
KEYWORD
nonn,easy
AUTHOR
Daniel Suteu, Jan 01 2016
STATUS
approved