OFFSET
0,4
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
Michael Gilleland, Some Self-Similar Integer Sequences
Ilya Gutkovskiy, Extended graphical example
FORMULA
a(n) = a(2*n) - a(2*n+1) for n > 1.
a(n+1) = 2*a(2*n+1) - a(2*n) for n > 1.
a(2^(k+1)+1) = phi^(2*k) + phi^(-2*k) = A005248(k).
a(2^(k+1)-1) = floor(phi^(2*k)) = A005592(k).
G.f. g(x) satisfies g(x) = (x + 2 + 1/x + 1/x^2)*g(x^2) - 1 - 2*x^2. - Robert Israel, Oct 24 2017
EXAMPLE
a(0) = 0; a(1) = a(2) = 1;
a(3) = a(2*1+1) = a(1) + a(2) = 2;
a(4) = a(2*2) = 2*a(2) + a(3) = 4;
a(5) = a(2*2+1) = a(2) + a(3) = 3;
a(6) = a(2*3) = 2*a(3) + a(4) = 8, etc.
G.f. = x + x^2 + 2*x^3 + 4*x^4 + 3*x^5 + 8*x^6 + 6*x^7 + 11*x^8 + 7*x^9 + 14*x^10 + ... - Michael Somos, Jul 24 2023
MAPLE
f:= proc(n) option remember;
if n::odd then procname((n+1)/2)+procname((n-1)/2)
else 2*procname(n/2)+procname(n/2+1)
fi
end proc:
f(0):= 0: f(1):= 1: f(2):= 1:
map(f, [$0..100]); # Robert Israel, Oct 24 2017
MATHEMATICA
a[0] = 0; a[1] = 1; a[2] = 1; a[n_] := If[EvenQ[n], 2 a[n/2] + a[(n + 2)/2], a[(n - 1)/2] + a[(n + 1)/2]]; Table[a[n], {n, 0, 70}]
PROG
(PARI) {a(n) = if(n<1, 0, n<3, 1, n%2, a(n\2) + a(n\2+1), 2*a(n\2) + a(n\2+1))}; /* Michael Somos, Jul 24 2023 */
CROSSREFS
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Oct 22 2017
STATUS
approved