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.

A160384 Number of nonzero digits in the base-3 representation of n.

Original entry on oeis.org

0, 1, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 3, 3, 2, 3, 3, 1, 2, 2, 2, 3, 3, 2, 3, 3, 1, 2, 2, 2, 3, 3, 2, 3, 3, 2, 3, 3, 3, 4, 4, 3, 4, 4, 2, 3, 3, 3, 4, 4, 3, 4, 4, 1, 2, 2, 2, 3, 3, 2, 3, 3, 2, 3, 3, 3, 4, 4, 3, 4, 4, 2, 3, 3, 3, 4, 4, 3, 4, 4, 1, 2, 2, 2, 3, 3, 2, 3, 3, 2, 3, 3, 3, 4, 4, 3, 4, 4, 2, 3, 3, 3, 4, 4
Offset: 0

Views

Author

Frank Ruskey, Jun 05 2009

Keywords

Programs

  • Mathematica
    Join[{0},Table[IntegerLength[n,3]-DigitCount[n,3,0],{n,110}]] (* Harvey P. Dale, Jun 21 2015 *)
  • PARI
    a(n)=my(d=digits(n,3)); sum(i=1,#d,!!d[i]) \\ Charles R Greathouse IV, Jan 13 2014

Formula

Recurrence relation: a(0) = 0, a(3m) = a(m), a(3m+1) = a(3m+2) = 1+a(m).
G.f.: (1/(1-z))*Sum_{m>=1} (z^(3^(m-1)) - z^(3^m))/(1 - z^(3^m)).
Morphism: 0, j -> j,j+1,j+1; e.g., 0 -> 011 -> 011122122 -> ...