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

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A007949 Greatest k such that 3^k divides n. Or, 3-adic valuation of n. 180

%I #192 Jul 20 2022 19:22:55

%S 0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,3,0,0,1,0,0,1,0,

%T 0,2,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,3,0,0,1,0,0,1,0,0,2,0,0,1,0,0,

%U 1,0,0,2,0,0,1,0,0,1,0,0,4,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1

%N Greatest k such that 3^k divides n. Or, 3-adic valuation of n.

%C Obeys the general recurrences for p-adic valuation discussed in A214411. - _Redjan Shabani_, Jul 17 2012

%C Lexicographically earliest cubefree sequence, which also (conjecturally) appears in the construction of the lexicographically earliest cubefree {0,1}-sequence A282317, cf. Example section of A286940. - _M. F. Hasler_, May 21 2017

%C The sequence is invariant under the "lower trim" operator: remove all zeros, and subtract one from each remaining term. - _Franklin T. Adams-Watters_, May 25 2017

%D F. Q. Gouvea, p-Adic Numbers, Springer-Verlag, 1993; see p. 23.

%H T. D. Noe, <a href="/A007949/b007949.txt">Table of n, a(n) for n = 1..1000</a>

%H K. Atanassov, <a href="http://nntdm.net/volume-04-1998/number-4/175-182/">On the 61-st, 62-nd and the 63-rd Smarandache Problems</a>, Notes on Number Theory and Discrete Mathematics, Sophia, Bulgaria, Vol. 4 (1998), No. 4, 175-182.

%H K. Atanassov, <a href="http://www.gallup.unm.edu/~smarandache/Atanassov-SomeProblems.pdf">On Some of Smarandache's Problems</a>, American Research Press, 1999, 16-21.

%H Dario T. de Castro, <a href="http://math.colgate.edu/~integers/w61/w61.pdf">P-adic Order of Positive Integers via Binomial Coefficients</a>, INTEGERS, Electronic J. of Combinatorial Number Theory, Vol. 22, Paper A61, 2022.

%H S. Northshield, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL18/Northshield/north4.html">An Analogue of Stern's Sequence for Z[sqrt(2)]</a>, Journal of Integer Sequences, 18 (2015), #15.11.6.

%H F. Smarandache, <a href="http://www.gallup.unm.edu/~smarandache/OPNS.pdf">Only Problems, Not Solutions!</a>.

%H M. Vassilev-Missana and K. Atanassov, <a href="http://nntdm.net/volume-04-1998/number-4/148-153/">Some Representations related to n!</a>, Notes on Number Theory and Discrete Mathematics, Vol. 4 (1998), No. 4, 148-153.

%H <a href="/index/Fi#FIXEDPOINTS">Index entries for sequences that are fixed points of mappings</a>

%F a(n) = 0 if n != 0 (mod 3), otherwise a(n) = 1 + a(n/3). - _Reinhard Zumkeller_, Aug 12 2001, edited by _M. F. Hasler_, Aug 11 2015

%F From _Ralf Stephan_, Apr 12 2002: (Start)

%F a(n) = A051064(n) - 1.

%F G.f.: Sum_{k>=1} x^3^k/(1 - x^3^k). (End)

%F Fixed point of the morphism: 0 -> 001; 1 -> 002; 2 -> 003; 3 -> 004; 4 -> 005; etc.; starting from a(1) = 0. - _Philippe Deléham_, Mar 29 2004

%F a(n) mod 2 = 1 - A014578(n). - _Reinhard Zumkeller_, Oct 04 2008

%F Totally additive with a(p) = 1 if p = 3, 0 otherwise.

%F v_{m}(n) = Sum_{r>=1} (r/m^(r+1)) Sum_{j=1..m-1} Sum_{k=0..m^(r+1)-1} exp((2*k*Pi*i*(n+(m-j)*m^r)) / m^(r+1)). This formula is for the general case; for this specific one, set m=3. - _A. Neves_, Oct 04 2010

%F a(3n) = A051064(n), a(2n) = a(n), a(2n-1) = A253786(n). - _Cyril Damamme_, Aug 04 2015

%F a(3n) = a(n) + 1, a(pn) = a(n) for any other prime p != 3. - _M. F. Hasler_, Aug 11 2015

%F 3^a(n) = A038500(n). - _Antti Karttunen_, Oct 09 2017

%F Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1/2. - _Amiram Eldar_, Jul 11 2020

%F a(n) = tau(n)/(tau(3*n) - tau(n)) - 1, where tau(n) = A000005(n). - _Peter Bala_, Jan 06 2021

%F a(n) = 3*Sum_{j=1..floor(log_3(n))} frac(binomial(n,3^j)*3^(j-1)/n). - _Dario T. de Castro_, Jul 10 2022

%p A007949 := proc(n) option remember; if n mod 3 > 0 then 0 else procname(n/3)+1; fi; end;

%p # alternative by _R. J. Mathar_, Mar 29 2017

%p A007949 := proc(n)

%p padic[ordp](n,3) ;

%p end proc:

%t p=3; Array[ If[ Mod[ #, p ]==0, Select[ FactorInteger[ # ], Function[ q, q[ [ 1 ] ]==p ], 1 ][ [ 1, 2 ] ], 0 ]&, 81 ]

%t Nest[ Function[ l, {Flatten[(l /. {0 -> {0, 0, 1}, 1 -> {0, 0, 2}, 2 -> {0, 0, 3}, 3 -> {0, 0, 4}}) ]}], {0}, 5] (* _Robert G. Wilson v_, Mar 03 2005 *)

%t IntegerExponent[Range[200], 3] (* _Zak Seidov_, Apr 15 2010 *)

%t Table[If[Mod[n, 3] > 0, 0, 1 + b[n/3]], {n, 200}] (* _Zak Seidov_, Apr 15 2010 *)

%o (PARI) a(n)=valuation(n,3)

%o (Haskell)

%o a007949 n = if m > 0 then 0 else 1 + a007949 n'

%o where (n', m) = divMod n 3

%o -- _Reinhard Zumkeller_, Jun 23 2013, May 14 2011

%o (MATLAB)

%o % Input:

%o % n: an integer

%o % Output:

%o % m: max power of 3 such that 3^m divides n

%o % M: 1-by-K matrix where M(i) is the max power of 3 such that 3^M(i) divides n

%o function [m,M] = Omega3(n)

%o M = NaN*zeros(1,n);

%o M(1)=0; M(2)=0; M(3)=0;

%o for k=4:n

%o if M(k-3)~=0

%o M(k)=M(k-k/3)+1;

%o else

%o M(k)=0;

%o end

%o end

%o m=M(end);

%o end

%o % _Redjan Shabani_, Jul 17 2012

%o (Sage) [valuation(n, 3) for n in (1..106)] # _Peter Luschny_, Nov 16 2012

%o (Magma) [Valuation(n, 3): n in [1..110]]; // _Bruno Berselli_, Aug 05 2013

%o (Scheme) (define (A007949 n) (let loop ((n n) (k 0)) (cond ((not (zero? (modulo n 3))) k) (else (loop (/ n 3) (+ 1 k)))))) ;; _Antti Karttunen_, Oct 06 2017

%o (Python)

%o def a(n):

%o k = 0

%o while n > 0 and n%3 == 0: n //= 3; k += 1

%o return k

%o print([a(n) for n in range(1, 106)]) # _Michael S. Branicky_, Aug 06 2021

%Y Partial sums give A054861.

%Y Cf. A000005, A038500, A080278, A001511, A122841, A007814, A112765, A253786.

%Y One less than A051064.

%K nonn,easy

%O 1,9

%A R. Muller

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 April 25 09:38 EDT 2024. Contains 371967 sequences. (Running on oeis4.)