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.
%I A004128 #70 Jun 10 2025 10:57:06 %S A004128 0,1,2,4,5,6,8,9,10,13,14,15,17,18,19,21,22,23,26,27,28,30,31,32,34, %T A004128 35,36,40,41,42,44,45,46,48,49,50,53,54,55,57,58,59,61,62,63,66,67,68, %U A004128 70,71,72,74,75,76,80,81,82,84,85,86,88,89,90,93,94,95,97,98,99,101,102 %N A004128 a(n) = Sum_{k=1..n} floor(3*n/3^k). %C A004128 3-adic valuation of (3n)!; cf. A054861. %C A004128 Denominators of expansion of (1-x)^{-1/3} are 3^a(n). Numerators are in |A067622|. %D A004128 Gary W. Adamson, in "Beyond Measure, A Guided Tour Through Nature, Myth and Number", by Jay Kappraff, World Scientific, 2002, p. 356. %H A004128 T. D. Noe, <a href="/A004128/b004128.txt">Table of n, a(n) for n = 0..1000</a> %H A004128 Vaclav Kotesovec, <a href="/A004128/a004128.jpg">Graph - the asymptotic ratio (100000 terms)</a> %F A004128 A051064(n) = a(n+1) - a(n). - _Alford Arnold_, Jul 19 2000 %F A004128 a(n) = n + floor(n/3) + floor(n/9) + floor(n/27) + ... = n + a(floor(n/3)) = n + A054861(n) = A054861(3n) = (3*n - A053735(n))/2. - _Henry Bottomley_, May 01 2001 %F A004128 a(n) = Sum_{k>=0} floor(n/3^k). a(n) = Sum_{k=0..floor(log_3(n))} floor(n/3^k), n >= 1. - _Hieronymus Fischer_, Aug 14 2007 %F A004128 Recurrence: a(n) = n + a(floor(n/3)); a(3n) = 3*n + a(n); a(n*3^m) = 3*n*(3^m-1)/2 + a(n). - _Hieronymus Fischer_, Aug 14 2007 %F A004128 a(k*3^m) = k*(3^(m+1)-1)/2, 0 <= k < 3, m >= 0. - _Hieronymus Fischer_, Aug 14 2007 %F A004128 Asymptotic behavior: a(n) = (3/2)*n + O(log(n)), a(n+1) - a(n) = O(log(n)); this follows from the inequalities below. - _Hieronymus Fischer_, Aug 14 2007 %F A004128 a(n) <= (3n-1)/2; equality holds for powers of 3. - _Hieronymus Fischer_, Aug 14 2007 %F A004128 a(n) >= (3n-2)/2 - floor(log_3(n)); equality holds for n = 3^m - 1, m > 0. - _Hieronymus Fischer_, Aug 14 2007 %F A004128 Lim inf (3n/2 - a(n)) = 1/2, for n->oo. - _Hieronymus Fischer_, Aug 14 2007 %F A004128 Lim sup (3n/2 - log_3(n) - a(n)) = 0, for n->oo. - _Hieronymus Fischer_, Aug 14 2007 %F A004128 Lim sup (a(n+1) - a(n) - log_3(n)) = 1, for n->oo. - _Hieronymus Fischer_, Aug 14 2007 %F A004128 G.f.: (Sum_{k>=0} x^(3^k)/(1-x^(3^k)))/(1-x). - _Hieronymus Fischer_, Aug 14 2007 %F A004128 a(n) = Sum_{k>=0} A030341(n,k)*A003462(k+1). - _Philippe Deléham_, Oct 21 2011 %F A004128 a(n) ~ 3*n/2 - log(n)/(2*log(3)). - _Vaclav Kotesovec_, Oct 17 2019 %p A004128 A004128 := proc(n) %p A004128 A054861(3*n) ; %p A004128 end proc: %p A004128 seq(A004128(n),n=0..100) ; # _R. J. Mathar_, Nov 04 2017 %t A004128 Table[Total[NestWhileList[Floor[#/3] &, n, # > 0 &]], {n, 0, 70}] (* _Birkas Gyorgy_, May 20 2012 *) %t A004128 A004128 = Log[3, CoefficientList[ Series[1/(1+x)^(1/3), {x, 0, 100}], x] // Denominator] (* _Jean-François Alcover_, Feb 19 2015 *) %t A004128 Flatten[{0, Accumulate[Table[IntegerExponent[3*n, 3], {n, 1, 100}]]}] (* _Vaclav Kotesovec_, Oct 17 2019 *) %o A004128 (PARI) {a(n) = my(s, t=1); while(t<=n, s += n\t; t*=3);s}; /* _Michael Somos_, Feb 26 2004 */ %o A004128 (PARI) a(n) = (3*n-sumdigits(n,3))/2; \\ _Christian Krause_, Jun 10 2025 %o A004128 (Sage) %o A004128 A004128 = lambda n: A004128(n//3) + n if n > 0 else 0 %o A004128 [A004128(n) for n in (0..70)] # _Peter Luschny_, Nov 16 2012 %o A004128 (Haskell) %o A004128 a004128 n = a004128_list !! (n-1) %o A004128 a004128_list = scanl (+) 0 a051064_list %o A004128 -- _Reinhard Zumkeller_, May 23 2013 %o A004128 (Magma) [n + Valuation(Factorial(n), 3): n in [0..70]]; // _Vincenzo Librandi_, Jun 12 2019 %o A004128 (Python) %o A004128 def A007949(n): %o A004128 c = 0 %o A004128 while not (a:=divmod(n,3))[1]: %o A004128 c += 1 %o A004128 n = a[0] %o A004128 return c %o A004128 def A004128(n): return n+sum(A007949(i) for i in range(3,n+1)) # _Chai Wah Wu_, Feb 28 2025 %Y A004128 Cf. A004117, A001511, A051064, A055457. %Y A004128 Cf. A054861, A067080, A098844, A132027, A005187, A054899. %K A004128 nonn %O A004128 0,3 %A A004128 _N. J. A. Sloane_ %E A004128 Current definition suggested by _Jason Earls_, Jul 04 2001