OFFSET
1,2
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
MAPLE
MATHEMATICA
a[1]=1; a[2]=2; a[3]=4; a[n_]:=a[n]=2a[n-1]+a[Floor[n/2]]; Array[a, 40] (* Harvey P. Dale, Aug 08 2019 *)
a[n_]:= a[n]= If[n<4, 2^(n-1), 2*a[n-1] + a[Floor[n/2]]]; Table[a[n], {n, 40}] (* G. C. Greubel, Oct 14 2019 *)
PROG
(PARI) a=vector(99, i, i*(i-1)/2+1); for(n=4, #a, a[n]=2*a[n-1]+a[n\2]); a \\ Charles R Greathouse IV, Nov 29 2011
(Magma) a:= func< n | n lt 4 select 2^(n-1) else 2*Self(n-1) + Self(Floor(n/2)) >;
[a(n): n in [1..40]]; // G. C. Greubel, Oct 14 2019
(Sage)
@CachedFunction
def a(n):
if (n<4): return 2^(n-1)
else: return 2*a(n-1) +a(floor(n/2))
[a(n) for n in (1..40)] # G. C. Greubel, Oct 14 2019
(GAP)
a:= function(n)
if n<4 then return 2^(n-1);
else return 2*a(n-1) + a(Int(n/2));
fi;
end;
List([1..40], n-> a(n) ); # G. C. Greubel, Oct 14 2019
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
STATUS
approved