%I #59 Nov 16 2022 06:55:20
%S 1,1,3,1,1,3,1,1,9,1,1,3,1,1,3,1,1,9,1,1,3,1,1,3,1,1,27,1,1,3,1,1,3,1,
%T 1,9,1,1,3,1,1,3,1,1,9,1,1,3,1,1,3,1,1,27,1,1,3,1,1,3,1,1,9,1,1,3,1,1,
%U 3,1,1,9,1,1,3,1,1,3,1,1,81
%N Highest power of 3 dividing n.
%C To construct the sequence: start with 1 and concatenate twice: 1,1,1 then tripling the last term gives: 1,1,3. Concatenating those 3 terms twice gives: 1,1,3,1,1,3,1,1,3, triple the last term -> 1,1,3,1,1,3,1,1,9. Concatenating those 9 terms twice gives: 1,1,3,1,1,3,1,1,9,1,1,3,1,1,3,1,1,9,1,1,3,1,1,3,1,1,9, triple the last term -> 1,1,3,1,1,3,1,1,9,1,1,3,1,1,3,1,1,9,1,1,3,1,1,3,1,1,27 etc. - _Benoit Cloitre_, Dec 17 2002
%C Also 3-adic value of 1/n, n >= 1. See the Mahler reference, definition on p. 7. This is a non-archimedean valuation. See Mahler, p. 10. Sometimes also called 3-adic absolute value. - _Wolfdieter Lang_, Jun 28 2014
%D Kurt Mahler, p-adic numbers and their functions, second ed., Cambridge University Press, 1981.
%H Reinhard Zumkeller, <a href="/A038500/b038500.txt">Table of n, a(n) for n = 1..10000</a>
%H Tyler Ball, Tom Edgar, and Daniel Juda, <a href="http://dx.doi.org/10.4169/math.mag.87.2.135">Dominance Orders, Generalized Binomial Coefficients, and Kummer's Theorem</a>, Mathematics Magazine, Vol. 87, No. 2, April 2014, pp. 135-143.
%H Zoran Sunic, <a href="https://arxiv.org/abs/math/0612080">Tree morphisms, transducers and integer sequences</a>, arXiv:math/0612080 [math.CO], 2006.
%F Multiplicative with a(p^e) = p^e if p = 3, 1 otherwise. - _Mitch Harris_, Apr 19 2005
%F a(n) = n / A038502(n). Dirichlet g.f. zeta(s)*(3^s-1)/(3^s-3). - _R. J. Mathar_, Jul 12 2012
%F From _Peter Bala_, Feb 21 2019: (Start)
%F a(n) = gcd(n,3^n).
%F O.g.f.: x/(1 - x) + 2*Sum_{n >= 1} 3^(n-1)*x^(3^n)/ (1 - x^(3^n)). (End)
%F Sum_{k=1..n} a(k) ~ (2/(3*log(3)))*n*log(n) + (2/3 + 2*(gamma-1)/(3*log(3)))*n, where gamma is Euler's constant (A001620). - _Amiram Eldar_, Nov 15 2022
%p A038500 := n -> 3^padic[ordp](n,3): # _Peter Luschny_, Nov 26 2010
%t Flatten[{1,1,#}&/@(3^IntegerExponent[#,3]&/@(3*Range[40]))] (* or *) hp3[n_]:=If[Divisible[n,3],3^IntegerExponent[n,3],1]; Array[hp3,90] (* _Harvey P. Dale_, Mar 24 2012 *)
%t Table[3^IntegerExponent[n, 3], {n, 100}] (* _Vincenzo Librandi_, Dec 29 2015 *)
%o (PARI) {a(n) = if( n<1, 0, 3^valuation(n, 3))};
%o (Haskell)
%o a038500 = f 1 where
%o f y x = if m == 0 then f (y * 3) x' else y where (x', m) = divMod x 3
%o -- _Reinhard Zumkeller_, Jul 06 2014
%o (Magma) [3^Valuation(n,3): n in [1..100]]; // _Vincenzo Librandi_, Dec 29 2015
%Y Cf. A001620, A007949, A038502, A060904, A268354, A268357.
%K nonn,mult
%O 1,3
%A _N. J. A. Sloane_
|