cache = vector(10 000)

a(n) = {
	if (n==0, return (1));
	if (cache[n]==0,
		cache[n] = if (n<=2, 1,
					   n%2,  1+a((n+1)/2)+a((n-1)/2),
						     1+a(n/2)+a(n/2-1)+a(n/2+1));
	);
	return (cache[n]);
}

for (n=0, #cache, print (n " " a(n)))

quit