OFFSET
0,4
LINKS
Altug Alkan, Table of n, a(n) for n = 0..10000
Altug Alkan, A scatterplot of a(n) for n <= 10^5
FORMULA
G.f. g(x) satisfies g(x) = (x+x^5)/(1-x^2)^2 - x*g(-x) - 2*g(x^2). - Robert Israel, Aug 28 2018
MAPLE
f:= proc(n) option remember;
if n::even then procname(n-1) - 2*procname(n/2)
else n-1-procname(n-1)
fi
end proc:
f(0):= 0: f(1):= 1:
map(f, [$0..100]); # Robert Israel, Aug 28 2018
MATHEMATICA
a[0]=0; a[1]=1; a[n_] := a[n] = If[EvenQ[n], a[n-1] - 2 a[n/2], n-1 - a[n - 1]]; Array[a, 70, 0] (* Giovanni Resta, Aug 27 2018 *)
PROG
(PARI) a(n)=if(n<=1, n, if(n%2==0, a(n-1)-2*a(n/2), n-1-a(n-1)));
(PARI) a = vector(99); print1 (0", "); for(n=1, #a, print1 (a[n]=if(n==1, 1, if(n%2, n-1-a[n-1], a[n-1]-2*a[n/2]))", "));
(Magma) [0] cat [n eq 1 select 1 else n mod 2 eq 0 select Self(n-1)-2*Self(n div 2) else n-1 - Self(n-1): n in [1..70]]; // Vincenzo Librandi, Aug 28 2018
CROSSREFS
KEYWORD
AUTHOR
Altug Alkan, Aug 20 2018
STATUS
approved