%I #25 Jun 24 2022 22:43:09
%S 0,1,0,3,2,3,0,1,0,7,6,7,4,5,4,7,6,7,0,1,0,3,2,3,0,1,0,15,14,15,12,13,
%T 12,15,14,15,8,9,8,11,10,11,8,9,8,15,14,15,12,13,12,15,14,15,0,1,0,3,
%U 2,3,0,1,0,7,6,7,4,5,4,7,6,7,0,1,0,3,2,3,0,1
%N a(n) = x(w+1) where x(0) = 0 and x(k+1) = 2^(k+1)-1-x(k) (resp. x(k)) when d_k = 1 (resp. d_k <> 1) and Sum_{k=0..w} d_k*3^k is the ternary representation of n. Sequence A332498 gives corresponding y's.
%C The representation of {(a(n), A332498(n))} is related to the T-square fractal (see illustration in Links section).
%C We can iteratively build the set {(a(n), A332498(n))} as follows:
%C - start with X_0 = {(0, 0)},
%C - for k = 0, 1, ..., X_{k+1} is obtained by adjoining to X_k:
%C - an horizontally mirrored copy of X_k to the right,
%C - and a vertically mirrored copy of X_k on the top,
%C - this corresponds to the following substitution:
%C .---.
%C .---. | V |
%C | X | --> .---.---.
%C .---. | X | H |
%C .---.---.
%H Rémy Sigrist, <a href="/A332497/b332497.txt">Table of n, a(n) for n = 0..6560</a>
%H Rémy Sigrist, <a href="/A332497/a332497.png">Representation of (a(n), A332498(n)) for n = 0..3^10-1</a>
%H Rémy Sigrist, <a href="https://practical-ardinghelli-959d8f.netlify.app/a332497">Interactive scatterplot of a 3D analog</a> [Provided your web browser supports the Plotly library, you should see icons on the top right corner of the page: if you choose "Orbital rotation", then you will be able to rotate the plot alongside three axes]
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/T-square_(fractal)">T-square (fractal)</a>
%F a(n) = 0 iff n belongs to A005823.
%e For n = 42:
%e - the ternary representation of 42 is "1120",
%e - x(0) = 0,
%e - x(1) = x(0) = 0 (as d_0 = 0 <> 1),
%e - x(2) = x(1) = 0 (as d_1 = 2 <> 1),
%e - x(3) = 2^3-1 - x(2) = 7 (as d_2 = 1),
%e - x(4) = 2^4-1 - x(3) = 8 (as d_3 = 1),
%e - hence a(42) = 8.
%o (PARI) a(n) = { my (x=0, k=1); while (n, if (n%3==1, x=2^k-1-x); n\=3; k++); x }
%Y See A332412 for a similar sequence.
%Y Cf. A005823, A332498 (corresponding y's).
%K nonn,base
%O 0,4
%A _Rémy Sigrist_, Feb 14 2020