<s>[INST] Explanation of formula for integer sequence with integers being repeated according to polynom I have two questions concerning OEIS sequence A056556:

$m$ is repeated $\frac{1}{2}(m+1)(m+2)$ times:
$$0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
 4, 4, 4, 4, 4, 4, 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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, ...$$
Formula: $a(n)=\lfloor x\rfloor$ where x is the (largest real) solution to
  $x^3+3x^2+2x-6n=0$



*

*Why is that formula correct?

*Is it possible to derive such a formula for any integer sequence where $m$ is repeated according to a polynom $p(m) = \sum_{i=0}^k c_i\ m^i$?

 [/INST] Let's study the cubic $\;P_n(x):=x^3+3x^2+2x-6n\,$
Its discriminant is given by $\;\Delta=4\,(1-243\,n^2)\,$ and will thus be negative for $n>0$ :
$P_n(x)$ will always have two conjugate complex solutions with negative real part and one real positive solution (thus the largest).
Since $\;P_n(x):=x(x+1)(x+2)-6\,n\ \ $ we will get the trivial solution $x=m,\  m\in\mathbb{N}$ when $n$ is a "tetrahedral number" A000292 i.e. when $\,n=T(m):=\dfrac {m(m+1)(m+2)}6$.
When $n$ is between two consecutive tetrahedral numbers $T(m)$ and $T(m+1)$ the largest root $x_0$ of $P_n(x_0)=0\,$ will still be given by $x_0=m_0$ but with $m_0$ the real solution of $n=T(m_0)=\dfrac {m_0(m_0+1)(m_0+2)}6\,$ belonging to $(m,m+1)$ and thus verify $\lfloor x_0\rfloor=m$.
(the function $m\mapsto n=T(m)$ is positive and smoothly increasing and thus the inverse function $n\mapsto m(n)=T^{-1}(n)\;$).
We found that for  $n$ in $[T(m),T(m+1))\;$ the largest root of $\;P_n(x):=x(x+1)(x+2)-6\,n\ \ $ verified $\lfloor x\rfloor=m\,$ but $[T(m),T(m+1))\;$ has $T(m+1)-T(m)=\dfrac {(m+1)(m+2)(m+3)}6-\dfrac {m(m+1)(t+2)}6=\dfrac {(m+1)(m+2)}2$ elements as wished with $\lfloor x\rfloor=m$.

This method may clearly be generalized to other polynomials of "ascending factorial type" : $x^{(n)}=x(x+1)(x+2)\cdots(x+n-1)\;$ but may be harder to handle in the general case (the "largest root" part and so on...).
Anyway a good starting point for a polynomial $p$ provided should be to search the polynomial $T$ such that : $\;T(m+1)-T(m)=p(m)$ (or define it recursively this way!). 
</s>