login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A134024 Number of positive trits in balanced ternary representation of n. 6
0, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 3, 3, 4, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 3, 3, 4, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 3, 3, 4, 2, 2, 3, 2, 2, 3, 3, 3, 4, 2 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,5

REFERENCES

D. E. Knuth, The Art of Computer Programming, Addison-Wesley, Reading, MA, Vol 2, pp 173-175.

LINKS

Reinhard Zumkeller, Table of n, a(n) for n = 0..10000

Wikipedia, Balanced Ternary

FORMULA

a(n) = A134021(n) - A134022(n) - A134023(n);

a(n) > 0 for n > 0.

a(n) = A005812(n) - A134022(n) = A134022(n) + A065363(n).

EXAMPLE

100=1*3^4+1*3^3-1*3^2+0*3^1+1*3^0=='++-0+': a(100)=3;

200=1*3^5-1*3^4+1*3^3+1*3^2+1*3^1-1*3^0=='+-+++-': a(200)=4;

300=1*3^5+1*3^4-1*3^3+0*3^2+1*3^1+0*3^0=='++-0+0': a(300)=3.

PROG

(Python)

def a(n):

    s=0

    x=0

    while n>0:

        x=n%3

        n=n/3

        if x==2:

            x=-1

            n+=1

        if x==1: s+=1

    return s

print [a(n) for n in range(151)] # Indranil Ghosh, Jun 07 2017

CROSSREFS

Cf. A005812, A065363, A134021, A134022, A134023.

Sequence in context: A088782 A291984 A066672 * A161069 A161108 A161043

Adjacent sequences:  A134021 A134022 A134023 * A134025 A134026 A134027

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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 29 10:41 EDT 2020. Contains 334699 sequences. (Running on oeis4.)