[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A318190
a(0) = 0, a(1) = 1; for n >= 1, a(2*n) = a(2*n-1) - 2*a(n), a(2*n+1) = 2*n - a(2*n).
2
0, 1, -1, 3, 5, -1, -7, 13, 3, 5, 7, 3, 17, -5, -31, 45, 39, -23, -33, 51, 37, -17, -23, 45, 11, 13, 23, 3, 65, -37, -127, 157, 79, -47, -1, 35, 101, -65, -167, 205, 131, -91, -57, 99, 145, -101, -191, 237, 215, -167, -193, 243, 197, -145, -151, 205, 75, -19, 55, 3, 257, -197, -511, 573, 415, -351, -257, 323, 325
OFFSET
0,4
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
Sequence in context: A208509 A086233 A353413 * A289714 A367743 A242390
KEYWORD
sign,easy,look
AUTHOR
Altug Alkan, Aug 20 2018
STATUS
approved