|
| |
|
|
A005812
|
|
Weight of balanced ternary representation of n.
(Formerly M0111)
|
|
5
| |
|
|
0, 1, 2, 1, 2, 3, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 4, 3, 2, 3, 4, 3, 4, 3, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 4, 3, 2, 3, 4, 3, 4, 5, 4, 5, 4, 3, 4, 5, 4, 5, 4, 3, 4, 3, 2, 3, 4, 3, 4, 5, 4, 5, 4, 3, 4, 5, 4, 5, 4, 3, 4, 3, 2, 3, 4, 3, 4, 3, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 4, 3, 2, 3, 4, 3, 4, 5, 4, 5, 4, 3, 4, 5, 4, 5, 4, 3
(list; graph; refs; listen; history; internal format)
|
|
|
|
OFFSET
| 0,3
|
|
|
COMMENTS
| Weight of n means count of nonzero digits of n. [From Daniel Forgues (squid(AT)zensearch.com), Mar 24 2010]
a(n) = A134022(n) + A134024(n) = A134021(n) - A134023(n).
|
|
|
REFERENCES
| Flajolet and Ramshaw, A note on Gray code..., SIAM J. Comput. 9 (1980), 142-158.
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
|
|
|
LINKS
| Daniel Forgues, Table of n, a(n) for n=0..100000
Michael Gilleland, Some Self-Similar Integer Sequences
|
|
|
FORMULA
| a(3n)=a(n), a(3n+1)=a(n)+1, a(9n+2)=a(n)+2, a(9n+5)=a(3n+2)+1, a(9n+8)=a(3n+2).
a(n) = sum{k>0, floor(|2*sin(n*pi/3^k)|)} - T. Suzuki (suzuki(AT)scio.co.jp), Sep 10 2006
|
|
|
MATHEMATICA
| a[n_] := With[{q=Round[n/3]}, Abs[n-3q]+a[q]]; a[0]=0; Table[a[n], {n, 0, 105}](* From Jean-François Alcover, Nov 25 2011, after Pari *)
|
|
|
PROG
| (Lisp) (defun btw (n) (if (= n 0) 0 (multiple-value-bind (q r) (round n 3) (+ (abs r) (btw q)))))
(PARI) a(n)=local(q); if(n<=0, 0, q=round(n/3); abs(n-3*q)+a(q))
|
|
|
CROSSREFS
| Sequence in context: A173964 A205710 A105499 * A136625 A086520 A012265
Adjacent sequences: A005809 A005810 A005811 * A005813 A005814 A005815
|
|
|
KEYWORD
| easy,nonn,nice
|
|
|
AUTHOR
| N. J. A. Sloane (njas(AT)research.att.com), Jeffrey Shallit. Additional terms from Allan Wechsler (acw(AT)alum.mit.edu)
|
| |
|
|