%I #45 Nov 15 2024 09:03:56
%S 1,1,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
%T 4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
%U 5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
%N k appears k*(k+1) times.
%C The current sequence is, loosely, the inverse function of the 2*binomial(n,3) sequence A007290.
%C A007290 has alternative formulas, thus yielding alternative formulas for the current sequence.
%C The formula below was inspired by Sum_{i = 0..n-2} (i*(i+1)) = n*(n-1)*(n-2)/3 given in A007290.
%C By definition: A002378 = run lengths. - _Reinhard Zumkeller_, Jan 01 2013
%C a(n) is the number of distinct terms of A007290 < n. - _Chai Wah Wu_, Nov 14 2024
%H Reinhard Zumkeller, <a href="/A220104/b220104.txt">Table of n, a(n) for n = 1..10000</a>
%F For c(n) = floor((3*n)^(1/3)), e(n) = n - (c(n)*(c(n)+1)*(c(n)+2))/3, explicit formula is a(n) = c(n) + sgn(abs(e(n)) + e(n)).
%F a(n) = floor(t + 1/(3*t)), where t = (3*(n - 1))^(1/3), for n > 1. - _Ridouane Oudra_, Oct 30 2023
%e For n = 21 the solution is found as the following: c(21) = 3, e(21) = 1, and finally a(21) = 4.
%t Flatten[Array[Table[#,#(#+1)]&,6]] (* _Paolo Xausa_, Dec 10 2023 *)
%o (Haskell)
%o a220104 n = a220104_list !! (n-1)
%o a220104_list = concatMap (\x -> take (a002378 x) $ repeat x) [1..]
%o -- _Reinhard Zumkeller_, Jan 01 2013
%o (Python)
%o from sympy import integer_nthroot
%o def A220104(n): return (m:=integer_nthroot(k:=3*n, 3)[0])+(k>m*(m+1)*(m+2)) # _Chai Wah Wu_, Nov 14 2024
%Y Cf. A002378, A007290.
%K nonn
%O 1,3
%A _Can Atilgan_ and Murat Erşen Berberler (muratersenberberler(AT)gmail.com), Dec 05 2012