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.

A051064 3^a(n) exactly divides 3n. Or, 3-adic valuation of 3n.

Original entry on oeis.org

1, 1, 2, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 2, 1, 1, 4, 1, 1, 2, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 2, 1, 1, 4, 1, 1, 2, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 2, 1, 1, 5, 1, 1, 2, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 2
Offset: 1

Views

Author

Keywords

Comments

a(n) is the Hamming distance between n and n-1 in ternary representation. - Philippe Deléham, Mar 29 2004
3^a(n) divides 4^n-1. - Benoit Cloitre, Oct 25 2004
Generalized Ruler Function for k=3. - Frank Ruskey and Chris Deugau (deugaucj(AT)uvic.ca)
a(A007417(n)) is odd and a(A145204(n)) is even. - Reinhard Zumkeller, May 23 2013
First n terms comprise least cubefree word of length n using positive integers, where "cubefree" means that the word contains no three consecutive identical subwords; e.g., 1 contains no cube; 11 contains no cube; 111 does but 112 does not; ... 1,1,2,1,1,2,1,1,1 does, and 1,1,2,1,1,2,1,1,2 does, but 1,1,2,1,1,2,1,1,3 does not, etc. - Clark Kimberling, Sep 10 2013
The sequence is invariant under the "lower trim" operator: remove all ones, and subtract one from each remaining term. - Franklin T. Adams-Watters, May 25 2017
a(n) is the dimension in which the coordinates of the vertices n-1 and n differ in the ternary reflected Gray code. - Arie Bos, Jul 12 2023
The number of powers of 3 that divide n. - Amiram Eldar, Mar 29 2025

Examples

			3^2 | 3*6 = 18, so a(6) = 2.
		

References

  • Letter from Gary W. Adamson to N. J. A. Sloane concerning Prouhet-Thue-Morse sequence, Nov. 11, 1999.

Crossrefs

Cf. A007949.
Partial sums give A004128.
Cf. A254046.

Programs

  • Haskell
    a051064 = (+ 1) . length .
                      takeWhile (== 3) . dropWhile (== 2) . a027746_row
    -- Reinhard Zumkeller, May 23 2013
    
  • Maple
    seq(1+padic:-ordp(n,3), n=1..100); # Robert Israel, Aug 07 2014
  • Mathematica
    Nest[ Function[ l, {Flatten[(l /. {1 -> {1, 1, 2}, 2 -> {1, 1, 3}, 3 -> {1, 1, 4}, 4 -> {1, 1, 5}})]}], {1}, 5] (* Robert G. Wilson v, Mar 03 2005 *)
    Table[ IntegerExponent[3n, 3], {n, 1, 105}] (* Jean-François Alcover, Oct 10 2011 *)
  • PARI
    a(n)=if(n<1,0,1+valuation(n,3))
    
  • Python
    def A051064(n):
        c = 1
        a, b = divmod(n,3)
        while b == 0:
            a, b = divmod(a,3)
            c += 1
        return c # Chai Wah Wu, Apr 18 2022

Formula

a(n) = A007949(n) + 1 = A004128(n) - A004128(n-1).
Multiplicative with a(p^e) = e+1 if p = 3; 1 if p <> 3. - Vladeta Jovovic, Aug 24 2002
G.f.: Sum_{k>=0} x^3^k/(1-x^3^k). - Ralf Stephan, Apr 12 2002
Fixed point of the morphism: 1 -> 112; 2 -> 113; 3 -> 114; 4 -> 115; ...; starting from a(1) = 1. a(3n+1) = a(3n+2) = 1; a(3n) = 1 + a(n). - Philippe Deléham, Mar 29 2004
a(n) = (-1)*Sum_{d divides n} mu(3d)*tau(n/d). - Benoit Cloitre, Jun 21 2007
Dirichlet g.f.: zeta(s)/(1-1/3^s). - R. J. Mathar, Jun 13 2011
a(n) = (1/2)*(3 - A053735(n) + A053735(n-1)) for n >= 1. - Tom Edgar, Aug 06 2014
a(n) = A007949(3n). - Cyril Damamme, Aug 04 2015
a(2n) = a(n), a(2n-1) = A254046(n). - Cyril Damamme, Aug 04 2015
G.f. A(x) satisfies: A(x) = A(x^3) + x/(1 - x). - Ilya Gutkovskiy, May 03 2019
Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 3/2. - Amiram Eldar, Sep 11 2020 [corrected by Vaclav Kotesovec, Jun 25 2024, see also A004128]
a(n) = tau(n)/(tau(3*n) - tau(n)), where tau(n) = A000005(n). - Peter Bala, Jan 06 2021
G.f.: Sum_{i>=1, j>=0} x^(i*3^j). - Seiichi Manyama, Mar 23 2025
Conjecture: a(n) = A007949(A000045(4*n)), all other 3-adic quadrisections A007949(A000045(.))=0. [Lengyel?]. - R. J. Mathar, Jun 28 2025

Extensions

More terms from James Sellers, Dec 11 1999
More terms from Vladeta Jovovic, Aug 24 2002