login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo

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 60th year, we have over 367,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Other ways to Give
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A134021 Length of n in balanced ternary representation. 20
1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
COMMENTS
Shifted variant of A064099.
a(n) = A134022(n) + A134023(n) + A134024(n);
0 <= a(n) - A081604(n) <= 1;
a(A134025(n))=A081604(A134025(n)); a(A134026(n))=A081604(A134026(n))+1;
a(A134027(n)) = a(n); a(ABS(A134028(n))) <= a(n);
a(n) = A064099(n-1) for n>1.
n = Sum(A059095(A134421(n)-2-k)*3^k: 0<=k<a(n)), for n>0. - Reinhard Zumkeller, Oct 25 2007
a(n) = A005812(n) + A134023(n).
REFERENCES
D. E. Knuth, The Art of Computer Programming, Addison-Wesley, Reading, MA, Vol 2, pp 173-175.
LINKS
Wikipedia, Balanced Ternary
FORMULA
For n>0: a(n) = ceiling(log(2*n+1)/log(3)).
EXAMPLE
100=1*3^4+1*3^3-1*3^2+0*3^1+1*3^0: a(100)=|++-0+|=5;
200=1*3^5-1*3^4+1*3^3+1*3^2+1*3^1-1*3^0: a(200)=|+-+++-|=6;
300=1*3^5+1*3^4-1*3^3+0*3^2+1*3^1+0*3^0: a(300)=|++-0+0|=6.
PROG
(Python)
def a(n):
if n==0: return 1
s=0
x=0
while n>0:
x=n%3
n=n//3
if x==2:
x=-1
n+=1
s+=1
return s
print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 07 2017
CROSSREFS
Sequence in context: A269024 A244160 A064099 * A330558 A237657 A244317
KEYWORD
nonn,base
AUTHOR
Reinhard Zumkeller, Oct 19 2007
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified December 9 13:48 EST 2023. Contains 367691 sequences. (Running on oeis4.)