login
This site is supported by donations 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. 113

%I

%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 a(n) mod 2 = 1 - A014578(n). - _Reinhard Zumkeller_, Oct 04 2008

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

%C Lexicographically earliest cube-free sequence, which also (conjecturally) appears in the construction of the lexicographically earliest cube-free {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 K. Atanassov, On the 61st, 62nd and the 63rd Smarandache Problems, Notes on Number Theory and Discrete Mathematics, Sophia, Bulgaria, Vol. 4 (1998), No. 4, 175-182.

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

%D M. Vassilev-Missana and K. Atanassov, Some Representations related to n!, Notes on Number Theory and Discrete Mathematics, Vol. 4 (1998), No. 4, 148-153.

%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://www.gallup.unm.edu/~smarandache/Atanassov-SomeProblems.pdf">On Some of Smarandache's Problems</a>, American Research Press, 1999, 16-21.

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

%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 <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), else 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 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

%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

%Y Partial sums give A054861. Cf. 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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified November 14 07:12 EST 2019. Contains 329111 sequences. (Running on oeis4.)