%I #51 Feb 12 2021 04:03:21
%S 0,0,1,0,0,2,1,1,2,0,0,1,0,0,3,2,2,3,1,1,2,1,1,3,2,2,3,0,0,1,0,0,2,1,
%T 1,2,0,0,1,0,0,4,3,3,4,2,2,3,2,2,4,3,3,4,1,1,2,1,1,3,2,2,3,1,1,2,1,1,
%U 4,3,3,4,2,2,3,2,2,4,3,3
%N 3-adic valuation of binomial(2*n, n): largest k such that 3^k divides binomial(2*n, n).
%C a(n) = 0 if and only if n is in A005836. - _Charles R Greathouse IV_, May 19 2013
%C sign(a(n+1) - a(n)) is repeat [0, 1, -1]. - _Filip Zaludek_, Oct 29 2016
%C By Kummer's theorem, number of carries when adding n + n in base 3. - _Robert Israel_, Oct 30 2016
%H Vincenzo Librandi, <a href="/A000989/b000989.txt">Table of n, a(n) for n = 0..2000</a>
%H Michael Gilleland, <a href="/selfsimilar.html">Some Self-Similar Integer Sequences</a>.
%H E. E. Kummer, <a href="https://doi.org/10.1515/crll.1852.44.93">Über die Ergänzungssätze zu den allgemeinen Reciprocitätsgesetzen</a>, Journal für die reine und angewandte Mathematik, Vol. 44 (1852), pp. 93-146; <a href="https://eudml.org/doc/147500">alternative link</a>.
%H Dorel Miheţ, <a href="https://doi.org/10.1007/s12045-010-0123-4">Legendre's and Kummer's theorems again</a>, Resonance, Vol. 15, No. 12 (2010), pp. 1111-1121; <a href="https://www.ias.ac.in/public/Volumes/reso/015/12/1111-1121.pdf">alternative link</a>.
%H Armin Straub, Victor H. Moll and Tewodros Amdeberhan, <a href="https://eudml.org/doc/278348">The p-adic valuation of k-central binomial coefficients</a>, Acta Arithmetica, Vol. 140, No. 1 (2009), pp. 31-42.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Kummer's_theorem">Kummer's theorem</a>.
%F a(n) = Sum_{k>=0} floor(2*n/3^k) - 2*Sum_{k>=0} floor(n/3^k). - _Benoit Cloitre_, Aug 26 2003
%F a(n) = A007949(A000984(n)). - _Reinhard Zumkeller_, Nov 19 2015
%F From _Robert Israel_, Oct 30 2016: (Start)
%F If 2*n < 3^k then a(3^k+n) = a(n).
%F If n < 3^k < 2*n then a(3^k+n) = a(n)+1.
%F If n < 3^k then a(2*3^k+n) = a(n)+1. (End)
%F a(n) = A053735(n) - A053735(2*n)/2. - _Amiram Eldar_, Feb 12 2021
%p f:= proc(n) option remember; local k,m,d;
%p k:= floor(log[3](n));
%p d:= floor(n/3^k);
%p m:= n-d*3^k;
%p if d = 2 or 2*m > 3^k then procname(m)+1
%p else procname(m)
%p fi
%p end proc:
%p f(0):= 0:
%p map(f, [$0..100]); # _Robert Israel_, Oct 30 2016
%t p=3; Array[ If[ Mod[ bi=Binomial[ 2#, # ], p ]==0, Select[ FactorInteger[ bi ], Function[ q, q[ [ 1 ] ]==p ], 1 ][ [ 1, 2 ] ], 0 ]&, 27*3, 0 ]
%t Table[ IntegerExponent[ Binomial[2 n, n], 3], {n, 0, 100}] (* _Jean-François Alcover_, Feb 15 2016 *)
%o (PARI) a(n) = valuation(binomial(2*n, n), 3)
%o (PARI) a(n)=my(N=2*n,s);while(N\=3,s+=N);while(n\=3,s-=2*n);s \\ _Charles R Greathouse IV_, May 19 2013
%o (Haskell)
%o a000989 = a007949 . a000984 -- _Reinhard Zumkeller_, Nov 19 2015
%Y Cf. A000984, A005836, A007949, A053735.
%K nonn,easy
%O 0,6
%A _N. J. A. Sloane_, _R. K. Guy_