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.

A094345 Sum of all digits in ternary expansions of 0, ..., n.

Original entry on oeis.org

0, 1, 3, 4, 6, 9, 11, 14, 18, 19, 21, 24, 26, 29, 33, 36, 40, 45, 47, 50, 54, 57, 61, 66, 70, 75, 81, 82, 84, 87, 89, 92, 96, 99, 103, 108, 110, 113, 117, 120, 124, 129, 133, 138, 144, 147, 151, 156, 160, 165, 171, 176, 182, 189, 191, 194, 198, 201, 205, 210, 214, 219
Offset: 0

Views

Author

Benoit Cloitre, Jun 08 2004

Keywords

References

  • Jean-Paul Allouche and Jeffrey Shallit, Automatic sequences, Cambridge University Press, 2003, p. 94.

Crossrefs

Programs

  • Mathematica
    a[n_] := Plus @@ IntegerDigits[n, 3]; Accumulate @ Array[a, 60, 0] (* Amiram Eldar, Dec 09 2021 *)
  • PARI
    s(k,n)=n-(k-1)*sum(m=1,n,valuation(m,k));
    a(n)=sum(i=0,n,s(3,i))
    
  • PARI
    a(n)= sum(i=1, n, sumdigits(i, 3)); \\ Ruud H.G. van Tol, Nov 19 2024

Formula

Asymptotically: a(n) = n*log(n)/log(3) + n*F(log(n)/log(3)) where F is a continuous function of period 1 nowhere differentiable (see Allouche & Shallit book).