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”).

A093347
A 3-fractal "castle" starting with 0.
10
0, 1, 0, 3, 2, 3, 0, 1, 0, 9, 8, 9, 6, 7, 6, 9, 8, 9, 0, 1, 0, 3, 2, 3, 0, 1, 0, 27, 26, 27, 24, 25, 24, 27, 26, 27, 18, 19, 18, 21, 20, 21, 18, 19, 18, 27, 26, 27, 24, 25, 24, 27, 26, 27, 0, 1, 0, 3, 2, 3, 0, 1, 0, 9, 8, 9, 6, 7, 6, 9, 8, 9, 0, 1, 0, 3, 2, 3, 0, 1, 0, 81, 80, 81, 78, 79, 78, 81
OFFSET
1,4
FORMULA
a(1) = 0 then a(n) = w(n) - a(n-w(n)) where w(n) = 3^floor(log(n-1)/log(3)).
a(3^n) = 0, a(3^n+1) = 3^n, a(3^n+2) = 3^n-1, a(3^n+3) = 3^n, etc.
a(n) = Sum_{i=1..n-1} (-1)^(i-1)*3^valuation(i, 3).
MATHEMATICA
a[n_] := Sum[(-1)^(i+1) * 3^IntegerExponent[i, 3], {i, 1, n-1}]; Array[a, 100] (* Amiram Eldar, Jun 17 2022 *)
PROG
(PARI) a(n)=if(n<2, 0, 3^floor(log(n-1)/log(3))-a(n-3^floor(log(n-1)/log(3))))
(PARI) a(n) = my(s=-1); fromdigits([if(d==1, s=-s) |d<-digits(n-1, 3)], 3); \\ Kevin Ryde, Jan 01 2024
CROSSREFS
Cf. A038500.
Sequence in context: A325142 A047160 A332497 * A230409 A244543 A283979
KEYWORD
nonn,easy
AUTHOR
Benoit Cloitre, Apr 26 2004
STATUS
approved