OFFSET
0,7
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..6560
Wikipedia, T-square (fractal)
FORMULA
a(n) = 0 iff n belongs to A005836.
EXAMPLE
For n = 42:
- the ternary representation of 42 is "1120",
- x(0) = 0,
- x(1) = x(0) = 0 (as d_0 = 0),
- x(2) = 2^2-1 - x(1) = 3 (as d_1 = 2),
- x(3) = x(2) = 3 (as d_2 = 1 <> 2),
- x(4) = x(3) = 3 (as d_3 = 1 <> 2),
- hence a(42) = 3.
PROG
(PARI) a(n) = { my (y=0, k=1); while (n, if (n%3==2, y=2^k-1-y); n\=3; k++); y }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Feb 14 2020
STATUS
approved