cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A093347 A 3-fractal "castle" starting with 0.

Original entry on oeis.org

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

Views

Author

Benoit Cloitre, Apr 26 2004

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := Sum[(-1)^(i+1) * 3^IntegerExponent[i, 3], {i, 1, n-1}]; Array[a, 100] (* Amiram Eldar, Jun 17 2022 *)
  • 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

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